redis-分段哈希(segment-hash)

故事扮演 提交于 2020-12-02 23:15:05
  1. 场景:
    用户id: userId,
    用户微博数量:weiboCount

  2. 实现方法:
    (1) 使用Redis字符串数据结构, userId为key, weiboCount作为Value
    (2) 使用Redis哈希结构,hashkey只有一个, key=“allUserWeiboCount”,field=userId,fieldValue= weiboCount
    (3) 使用Redis哈希结构, hashkey为多个, key=userId/100, field=userId%100, fieldValue= weiboCount
    前两种比较容易理解,第三种方案解释一下:每个hashKey存放100个hash-kv,field=userId%100。



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!