If I set an 8-bit bitfield at position 0, I would expect the resulting string to be of length = 1 byte, but actually it is 2.

For example:

redis> FLUSHALL
OK

redis> BITFIELD key set u8 0 0
1) (integer) 0

redis> STRLEN key
(integer) 2

redis> GET key
"\x00\x00"

Is this the expected behavior?

Comment From: oranagra

for the record, in redis 6.0 it seems to match your expectations:

redis> bitfield key set u8 0 0
1) (integer) 0
redis> strlen key
(integer) 1
redis> get key
"\u0000"