当前位置:网站首页>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 5
At 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 6
Inquiry, here are 2 items as one page, first count the number of items
llen a_comments
Get 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 5
Defects
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.
边栏推荐
- Know the showTimePicker method of the basic components of Flutter
- 安全20220718
- Day32 LeetCode
- web容器及IIS --- 中间件渗透方法1
- VS QT - ui does not display newly added members (controls) || code is silent
- LeetCode每日一练 —— OR36 链表的回文结构
- Implementation of a sequence table
- MP使用时的几个常见报错
- MultipartFile文件上传
- 7年经验,功能测试工程师该如何一步步提升自己的能力呢?
猜你喜欢
Daily practice of LeetCode - palindrome structure of OR36 linked list
No qualifying bean of type 问题
大小端模式
[Compilation principle] Lexical analysis program design principle and implementation
MP使用时的几个常见报错
The application and practice of mid-to-platform brand advertising platform
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
$attrs/$listeners
浅识Flutter 基本组件之CheckBox组件
随机推荐
【AUTOSAR-RTE】-4-Port和Interface以及Data Type
LeetCode每日一练 —— OR36 链表的回文结构
TCP和UDP详解
端口排查步骤-7680端口分析-Dosvc服务
7年经验,功能测试工程师该如何一步步提升自己的能力呢?
选好冒烟测试用例,为进入QA的制品包把好第一道关
PMP微信群日常习题
els block to the right
安全20220722
addressable in Golang
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
How to develop a high-quality test case?
[Compilation principle] Design principle and implementation of recursive descent parsing
顺序表的实现
Redis implements distributed locks
观察者模式
TCP详解(三)
IIR filter and FIR filter
Daily practice of LeetCode - palindrome structure of OR36 linked list
Analysis summary - self-use