redis 哈希里存哈希_如何使用Redis哈希

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 here.

在此处查看所有哈希命令。

翻译自: https://flaviocopes.com/redis-hashes/

redis 哈希里存哈希

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值