当前位置:网站首页>Redis uses LIST to cache the latest comments
Redis uses LIST to cache the latest comments
2022-07-31 03:32:00 【Mar, fleeting】
Article table of contents
implemented
Assuming product a, there are currently five reviews 1, 2, 3, 4, and 5.Synchronized from database to redis, here we require the latest comment to be placed at the top of the queue.
lpush a_comments 1lpush a_comments 2lpush a_comments 3lpush a_comments 4lpush a_comments 5At this time, the user has a new comment 6 on a, which is entered into the database first, and then into redis
lpush a_comments 6Inquiry, here are 2 items as one page, first count the number of items
llen a_commentsGet 6 pieces of data, the number of pages 6/2 = 3
The latest comment pagination data
# first page 6,5lrange a_comments 0 1# Second page 4,3lrange a_comments 2 3# 3rd page 2,1 lrange a_comments 4 5Defects
It doesn't seem like there is a problem with the above, assuming you are looking at the first page of comments now, you see 6,5.At this time, a new comment 7 is generated and added to the head of the team.At this point you are looking at the second page, it is not 4,3.Instead 5, 4.You have clearly read these 5 on the first page.
边栏推荐
- What skills do I need to learn to move from manual testing to automated testing?
- els 方块向右移
- addressable in Golang
- TCP和UDP详解
- 安全20220709
- LeetCode简单题之两个数组间的距离值
- 测试中的误报和漏报同样的值得反复修正
- Ambiguous method call.both
- Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
- [Compilation principle] Lexical analysis program design principle and implementation
猜你喜欢
随机推荐
STM32 problem collection
[C language] General method of expression evaluation
Several common errors when using MP
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
The application and practice of mid-to-platform brand advertising platform
LeetCode简单题之两个数组间的距离值
RESTful api接口设计规范
Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
LeetCode中等题之分数加减运算
errno错误码及含义(中文)
els 方块向左移动条件判断
beforeDestroy与destroyed的使用
浅识Flutter 基本组件之CheckboxListTile组件
分布式系统架构需要解决的问题
进程间通信
Know the showTimePicker method of the basic components of Flutter
下载jar包的好地方
SocialFi 何以成就 Web3 去中心化社交未来
The Map Entry understanding and application
[Compilation principle] Lexical analysis program design principle and implementation








