When using the Redis expire commands like SETEX
and TTL
, there are scenarios in which there is no need for the key to hold a value at all, because the time to live acts as such.
However, Redis requires any key to have a value.
What would be the most reasonable value to use - if you don't ever want to read it?
redis is an in-memory, key/value store. Think of it as a dictionary with any number of keys, each of which has a value that can be set or retrieved. However, Redis goes beyond a simple key/value store as it is actually a data structures server, supporting different kinds of values.
Redis client to store a Null value in Redis? If you use IDatabase. StringGet(key) then the returning of Null is used to signify that there "was no result". Therefore if you use IDatabase.
Redis SET command is used to set some string value in redis key. If the key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on a successful SET operation. 1.0.
As we have mentioned earlier that Redis is a key-value store, but that doesn't mean that it stores only string keys and string values. Redis supports different types of data structures as values. The key in Redis is a binary-safe String, with a max size of 512 MB, but you should always consider creating shorter keys.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With