复杂的数据结构Redis [英] Complex data structures Redis

查看:39
本文介绍了复杂的数据结构Redis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个散列的散列,例如

Lets say I have a hash of a hash e.g.

$data = {
    'harry' : {
         'age' : 25,
         'weight' : 75,
    },
    'sally' : {
        'age' : 25,
        'weight' : 75,
    }
}

  1. 存储这种数据结构的通常"方式是什么(或者你不会?)
  2. 您能否直接获取一个值(例如获取 harry : age ?
  3. 一旦存储,您是否可以直接更改子键的值(例如 sally : weight = 100)

推荐答案

存储这种数据结构的通常"方式是什么(或者将你没有?)

What would the 'usual' way to store such a data structure (or would you not?)

例如,harry 和 sally 将分别存储在单独的 哈希 中,其中的字段将代表他们的属性,例如年龄和重量.然后 set 结构将保存您存储在 redis 中的所有成员(harry、sally 等).

For example harry and sally would be stored each in separate hashes where fields would represent their properties like age and weight. Then set structure would hold all the members (harry, sally, ...) which you have stored in redis.

你能直接得到一个值吗(比如得到 harry : age ?)

Would you be able to directly get a value (e.g. get harry : age ?)

是的,请参阅 HGETHMGETHGETALL.

Yes, see HGET or HMGET or HGETALL.

一旦存储,您是否可以直接更改子键的值(例如莎莉:体重 = 100)

Once stored could you directly change the value of a sub key (e.g. sally : weight = 100)

是的,请参阅 HSET.

这篇关于复杂的数据结构Redis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆