Pav*_* S. 6 redis data-structures
Redis可以直接用作键值存储,其值为string.或者,以更复杂的方式,值可以是数据结构,例如散列或列表.假设我们有第二种情况并且在键"H"下,则存在哈希.可以将项添加到哈希并删除.最终,哈希可以为空,并且可以再次重新填充.
我发现如果我们从数据结构中删除最后一项,我们的哈希值为"H",由于某种原因,Redis将其从当前键中删除.
例:
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
Run Code Online (Sandbox Code Playgroud)
我的问题是:是否有可能配置的Redis所以它仍然继续显示(在我们的例子空的散列)的值给定键("H",在我们的例子)作为空不平凡的数据结构?