redis hashmap

redis hashmap数据结构,使用散列来组织数据。对于一条有多个属性的数据可以通过hashmap来存储数据。

A hash with a few fields (where few means up to one hundred or so) is stored in a way that takes very little space, so you can store millions of objects in a small Redis instance.
While Hashes are used mainly to represent objects, they are capable of storing many elements, so you can use Hashes for many other tasks as well.
Every hash can store up to 232 - 1 field-value pairs (more than 4 billion).

根据redis官网介绍,redis一个hashmap可以存储(2的32次方-1)个属性。对于一条拥有属性(fields)数量在100左右的数据,redis官网推荐使用hashmap进行数据存储。
当每个hashmap属性数量小于hash-max-ziplist-entries设置值,且每fields的字节量小于hash-max-ziplist-value设置值时。redis对hashmap进行优化使用zipList数据结构进行存储,可以降低redis对hashmap的存储的空间消耗,提升存储性能,但是基于zipList结构的hashmap相比于基于Hash结构的HashMap来说,频繁的更新数据会造成更多的内存交换,因为当类似数组结构的zipList其中某个节点值改变后,后续的节点数据会根据更新数据的大小在链表中向前向后移动,更新性能会相对降低。

参考文献:
https://redis.io/topics/memory-optimization

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值