Redis store key without a value

I would avoid using "". How about simple 0 ?

127.0.0.1:6379> set akey 0
OK
127.0.0.1:6379> memory usage akey
(integer) 48
127.0.0.1:6379> set akey ""
OK
127.0.0.1:6379> memory usage akey
(integer) 50
127.0.0.1:6379>

I would store one byte of data that could also be broadly interpreted as "truthy", such as the ASCII character 1.


Who said that you should actually store anything in redis key?

Empty string "" is a perfectly valid value for a redis key, and it's a shortest possible one:

> SET foo ""
OK
> GET foo
""
> BITCOUNT foo
(integer) 0

Tags:

Ttl

Redis