redis中hash表內(nèi)容刪除的方法代碼
更新時間:2019年07月05日 08:37:32 作者:尚
在本篇文章里小編給各位整理了關于redis中hash表內(nèi)容怎么刪除的方法以及技巧代碼,需要的朋友們分享下。
hash:
Redis hash是一個string類型的field和value的映射表,hash特別適合用于存儲對象。
Redis 中每個hash可以存儲 232 - 1鍵值對(40多億)。
實例:
127.0.0.1:6379> HMSET runoobkey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000 OK 127.0.0.1:6379> HGETALL runoobkey 1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000"
刪除命令:
Hdel命令
Redis Hdel命令用于刪除哈希表key中的一個或多個指定字段,不存在的字段將被忽略。
redis Hdel 命令基本語法如下:
redis 127.0.0.1:6379> HDEL KEY_NAME FIELD1.. FIELDN
返回值:
被成功刪除字段的數(shù)量,不包括被忽略的字段。
redis 127.0.0.1:6379> HSET myhash field1 "foo" (integer) 1 redis 127.0.0.1:6379> HDEL myhash field1 (integer) 1 redis 127.0.0.1:6379> HDEL myhash field2 (integer) 0
內(nèi)容擴展:
Redis Hdel 命令用于刪除哈希表 key 中的一個或多個指定字段,不存在的字段將被忽略。
語法
redis Hdel 命令基本語法如下:
redis 127.0.0.1:6379> HDEL KEY_NAME FIELD1.. FIELDN
可用版本
>= 2.0.0
返回值
被成功刪除字段的數(shù)量,不包括被忽略的字段。
實例
redis 127.0.0.1:6379> HSET myhash field1 "foo" (integer) 1 redis 127.0.0.1:6379> HDEL myhash field1 (integer) 1 redis 127.0.0.1:6379> HDEL myhash field2 (integer) 0
相關文章
為何Redis使用跳表而非紅黑樹實現(xiàn)SortedSet
本篇文章主要介紹了為何Redis使用跳表而非紅黑樹實現(xiàn)SortedSet,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-09-09

