当前位置:网站首页>Redis uses sorted set to cache latest comments
Redis uses sorted set to cache latest comments
2022-07-31 03:31:00 【Mar, fleeting】
Article table of contents
Foreword
sorted set is an ordered set.The attribute of weight is provided, and data can be obtained according to the weight.
implemented
Assuming that there are reviews 11, 22, 33, 44, 55 for product A now, the weights are accumulated from 1 (+1) according to the order of reviews.
zadd a_comments 1 11zadd a_comments 2 22zadd a_comments 3 33zadd a_comments 4 44zadd a_comments 5 55A new comment 66 was generated at this time.Determine the weight of comment 66 (total + 1)
# Get the total number of 5 and determine the weight of 6zcard a_comments# add to rediszadd a_comments 6 66View the latest comments, 2 records per page.
# Get the current amountzcard a_comments# First page 55,66zrangebyscore a_comments 5 6# 2nd page 33,44zrangebyscore a_comments 3 4# 3rd page 11,22zrangebyscore a_comments 1 2边栏推荐
- 组件传值 provide/inject
- Redis 使用 sorted set 做最新评论缓存
- 【AUTOSAR-RTE】-5-Explicit(显式)和Implicit(隐式) Sender-Receiver communication
- Atomic operation CAS
- VS QT - ui does not display newly added members (controls) || code is silent
- 浅识Flutter 基本组件之CheckBox组件
- els block to the right
- What skills do I need to learn to move from manual testing to automated testing?
- C primer plus学习笔记 —— 8、结构体
- Redis实现分布式锁
猜你喜欢

VS QT——ui不显示新添加成员(控件)||代码无提示
![[C language] Three-pointed chess (classic solution + list diagram)](/img/64/18ed08b64f9618bbd7f24ee16e6a6f.jpg)
[C language] Three-pointed chess (classic solution + list diagram)

Mysql 45讲学习笔记(二十四)MYSQL主从一致

Office automation case: how to automatically generate period data?

Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢

7年经验,功能测试工程师该如何一步步提升自己的能力呢?

The application and practice of mid-to-platform brand advertising platform

Redis实现分布式锁

TCP和UDP详解

【编译原理】递归下降语法分析设计原理与实现
随机推荐
从滴滴罚款后数据治理思考
web容器及IIS --- 中间件渗透方法1
Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢
What is SQALE
Detailed explanation of TCP (2)
IIR filter and FIR filter
Redis implements distributed locks
MultipartFile文件上传
LeetCode每日一练 —— OR36 链表的回文结构
【编译原理】词法分析程序设计原理与实现
[Godot][GDScript] 2D cave map randomly generated
Implementation of a sequence table
Several common errors when using MP
Key Technologies of Interface Testing
Analysis summary - self-use
选好冒烟测试用例,为进入QA的制品包把好第一道关
Recursive query single table - single table tree structure - (self-use)
SocialFi 何以成就 Web3 去中心化社交未来
C primer plus学习笔记 —— 8、结构体
点云DBSCAN聚类(MATLAB,非内置函数)