当前位置:网站首页>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 55
A 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 66
View 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
边栏推荐
- What is a system?
- What skills do I need to learn to move from manual testing to automated testing?
- Detailed explanation of TCP (1)
- Day32 LeetCode
- 安全20220722
- 选好冒烟测试用例,为进入QA的制品包把好第一道关
- [Compilation principle] Lexical analysis program design principle and implementation
- [C language] Preprocessing operation
- 5. How does the SAP ABAP OData service support the $filter operation
- C primer plus study notes - 8, structure
猜你喜欢
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
Database implements distributed locks
刚出道“一战成名”,安全、舒适一个不落
Know the showTimePicker method of the basic components of Flutter
Key Technologies of Interface Testing
No qualifying bean of type 问题
Mysql 45 study notes (23) How does MYSQL ensure that data is not lost
10 Permission introduction
IIR filter and FIR filter
Redis implements distributed locks
随机推荐
Map.Entry理解和应用
浅识Flutter 基本组件之CheckBox组件
Golang中的addressable
【编译原理】词法分析程序设计原理与实现
Use of QML
SQL injection Less47 (error injection) and Less49 (time blind injection)
SIP协议标准和实现机制
Day32 LeetCode
Annotation usage meaning
Know the showTimePicker method of the basic components of Flutter
A brief introduction to the CheckboxListTile component of the basic components of Flutter
some of my own thoughts
The application and practice of mid-to-platform brand advertising platform
C# remote debugging
想从手工测试转岗自动化测试,需要学习哪些技能?
自己的一些思考
Key Technologies of Interface Testing
解析小结—自用
Getting Started with CefSharp - winform
数据库实现分布式锁