Redis set vs hash

前端 未结 3 1445
自闭症患者
自闭症患者 2020-12-12 18:12

In many Redis tutorials (such as this one), data is stored in a set, but with multiple values combined together in a string (i.e. a user account might be stored in the set a

3条回答
  •  生来不讨喜
    2020-12-12 18:39

    Hashes are one of the most efficient methods to store data in Redis, even going so far as to recommending them for use whenever effectively possible.

    http://redis.io/topics/memory-optimization

    Use hashes when possible

    Small hashes are encoded in a very small space, so you should try representing your data using hashes every time it is possible. For instance if you have objects representing users in a web application, instead of using different keys for name, surname, email, password, use a single hash with all the required fields.

提交回复
热议问题