计数器
INCR article:readcount:{文章id}
GET article:readcount:{文章id}
Web集群session共享
spring session +redis实现session共享
分布式系统全局序列号
INCRBY orderId 1000
电商购物车
1)以用户id为key
2)商品id为field
3)商品数量为value
购物车操作
1)添加商品->hset cart:1001 10088 1
2)增加数量->hincrby cart:1001 10088 1
3)商品总数->hlen cart:1001
4)删除商品->hdelcart:1001 10088
5)获取购物车所有商品->hgetall cart:1001
优点
1)同类数据归类整理储存,方便数据管理
2)相比string操作消耗内存更小
3)相比string储存更节省空间
缺点
1)过期功能不能使用在field上,只能用在key上
2)Redis集群架构下不适合大规模使用