本文共 767 字,大约阅读时间需要 2 分钟。
redis 哈希里存哈希
So far with Lists and Sets we saw how to correlate a key with a value, or a group of values.
到目前为止,我们已经通过列表和集合了解了如何将键与一个值或一组值相关联。
Hashes let us associate more than one value to a single key, and they are perfect to store object-like items.
哈希使我们可以将多个值关联到单个键,并且它们非常适合存储类似对象的项。
For example, a person has a name and an age.
例如,一个人有名字和年龄。
We can create a person:1
hash:
我们可以创建一个person:1
哈希:
HMSET person:1 name "Flavio" age 37
To get all the properties of a user, use HGETALL
:
要获取用户的所有属性,请使用HGETALL
:
HGETALL person:1
You can update a hash property using HSET
:
您可以使用HSET
更新哈希属性:
HSET person:1 age 38
You can increment a value stored in a hash using HINCRBY
:
您可以使用HINCRBY
增加存储在哈希中的值:
HINCRBY person:1 age 2
See all the hash commands .
查看所有哈希命令。
翻译自:
redis 哈希里存哈希
转载地址:http://zxmgb.baihongyu.com/