Store blank data keys in Redis

Redis can be used either directly as a keystore, where the value is a string. Or in a more complex way, it could be a data structure, such as a hash or a list. Assuming we have a second case and under the key "H", there is a hash. Elements can be added to the hash and deleted. In the end, the hash can be empty and can be re-filled again.

I found out that if we remove the last element from the data structure, our hash is “H”, Redis removes it from the current keys for some reason.

Example:

HSET "H" "key1" "value1"
HSET "H" "key2" "value2"
HDEL "H" "key1"
 <-- Here, "H" is in the list of current keys, whereby HLEN returns 1
HDEL "H" "key2"
 <-- Here, for some reason, "H" is not shown among existing keys, 
     not even as an empty hash (HLEN 0)
HSET "H" "key3" "value3"
 <-- Hash is back in the list of keys

My question is: is it possible to configure Redis so that it still shows the value (empty hash in our example) of this key ("H" in our example) as an empty nontrivial data structure

+4
2

:

Redis , " " . Redis 2.8, " ".

+7
. .

, , . , Redis Hash, , , . , , .

?

update: , .

"" - . KEYS ( SCAN) SET, , . - "last_seen_keys" . , KEYS , "current_keys". diff , , , . statsd . SET "last_seen_keys" SET "current_keys" "last_seen_keys" .

+2

All Articles