- 场景:
用户id: userId,
用户微博数量:weiboCount - 实现方法:
(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。
来源:oschina
链接:https://my.oschina.net/u/4408053/blog/4769787