redis hash 是乙個string型別的field和value的對映表,hash特別適合用於儲存物件。
redis 中每個 hash 可以儲存 232 - 1 鍵值對(40多億)。
例項
在以上例項中,我們設定了 redis 的一些描述資訊(name, description, likes, visitors) 到雜湊表的 mykey 中。127.0.0.1:6379> hmset mykey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000
ok127.0.0.1:6379> hgetall mykey
1) "name"
2) "redis tutorial"
3) "description"
4) "redis basic commands for caching"
5) "likes"
6) "20"
7) "visitors"
8) "23000"
序號命令及描述
hdel key field1 [field2]
刪除乙個或多個雜湊表字段
hexists key field
檢視雜湊表 key 中,指定的字段是否存在。
hget key field
獲取儲存在雜湊表中指定欄位的值。
hgetall key
獲取在雜湊表中指定 key 的所有欄位和值
hincrby key field increment
為雜湊表 key 中的指定欄位的整數值加上增量 increment 。
hincrbyfloat key field increment
為雜湊表 key 中的指定欄位的浮點數值加上增量 increment 。
hkeys key
獲取所有雜湊表中的字段
hlen key
獲取雜湊表中字段的數量
hmget key field1 [field2]
獲取所有給定欄位的值
hmset key field1 value1 [field2 value2 ]
同時將多個 field-value (域-值)對設定到雜湊表 key 中。
hset key field value
將雜湊表 key 中的字段 field 的值設為 value 。
hsetnx key field value
只有在字段 field 不存在時,設定雜湊表字段的值。
hvals key
獲取雜湊表中所有值
hscan key cursor [match pattern] [count count]
迭代雜湊表中的鍵值對。
參考:
Redis 雜湊 Hash 命令
redis hash 是乙個 string 型別的 field 字段 和 value 值 的對映表,hash 特別適合用於儲存物件。描述 命令hset 將雜湊表key中的字段field的值設為value hgetall 獲取在雜湊表中指定key的所有欄位和值 hget 獲取儲存在雜湊表中指定欄位的值...
Redis 雜湊 Hash 命令
redis hash 是乙個 string 型別的 field 字段 和 value 值 的對映表,hash 特別適合用於儲存物件。redis 中每個 hash 可以儲存 2 32 1 鍵值對 40多億 127.0.0.1 6379 hmset mykey name redis tutorial d...
redis必殺命令 雜湊 Hash
題記 redis hash 是乙個string型別的field和value的對映表,hash特別適合用於儲存物件。redis 中每個 hash 可以儲存 232 1 鍵值對 40多億 例如 127.0.0.1 6379 hmset xiongben name 王棟 desc 今年24歲 likes ...