当前位置:网站首页>Redis实现分页
Redis实现分页
2022-06-09 15:54:00 【仙狐酱ღ】
redis 实现分页
使用有序集合 zadd
使用 hash 存储具体的数据
取数据通过有序集合的 ZREVRANGE— 递减排序
代码案例
//按时间降序进行排序
//存数据
$redis->zAdd($key,$article['add_time'],'article:'.$artice['id']);
$redis->hMset('article'.$article['id'],$article);
//取数据
$result = $redis->zRevRange($key,$start,$start+10,true); //获取到数据,每一次10条数据
$count = $redis->ZCARD($key); //获取总条数
foreach($result as $k=>$v){
$article = $reids->hGetAll($k) //每一篇文章的具体数据
}边栏推荐
- 618's money saving technology strategy is coming - experience the scene and get a 10 yuan cat super card!
- Is it safe to open a new bond? How to open an account
- Kubernetes core concepts
- 基于 abp vNext 的快速开发模板
- Moonriver Network与Calamari Network完成XCM集成
- 五月集训(第24天) —— 线段树
- 字节一面:网站显示不出来,怎么排查?
- May training (day 22) - orderly gathering
- R language generalized linear model function GLM, GLM function to build logistic regression model, analyze whether the model is over dispersed, and use hypothesis test to analyze whether the model is
- 关闭StackExchange等平台的privacy收集窗口
猜你喜欢

看完就会,从抓包到接口测试的全过程解析

Win10找不到飞行模式开关怎么办?

67 2D绘图(反走样绘图 / 抗锯齿渲染)

测试必看,初次编写测试用例的要点

30-year-old mind map

ASEMI的MOS管9N90参数,9N90电路图,9N90实物图

合约安全之-变量隐藏安全问题分析

FFmpeg思维导图

Experience sharing of technical we media realization -- starting to try to make CSDN's reply one year later

Data security is urgent. What is the significance of the first SOC 2 authentication report for domestic intelligent manufacturers?
随机推荐
疫情之下,四点认知助你成长!
"CSDN powder raising strategy" 11 powder raising methods, how many have you learned?
单体应用和微服务调用区别
若依 思维导图
关闭StackExchange等平台的privacy收集窗口
Build an integrated intelligent dialogue analysis platform from intelligent quality inspection to dialogue analysis, and the customer service center of Bank of Hangzhou creates a new business card of
LeetCode 327. Number of interval sums
Golang reflect: code examples for reflecting (obtaining values) basic data types and struct structures
June training (day 01) - array
Differences between containers and mirrors
R language generalized linear model function GLM, GLM function to build logistic regression model, analyze whether the model is over dispersed, and use hypothesis test to analyze whether the model is
R语言使用aov函数进行双因素方差分析(Two-way factorial ANOVA)、gplots包的plotmeans函数在双因素方差分析中显示交互作用、包括均值,误差条、95%置信区间、样本量
五月集训(第28天) —— 动态规划
Experience sharing of technical we media realization -- starting to try to make CSDN's reply one year later
LeetCode 6077. The total power of wizards and
如何高效学习 思维导图
站长工具浏览器SEO插件-站长必备工具 SEO网站排名 快速查看网站数据
字节一面:网站显示不出来,怎么排查?
基于 abp vNext 的快速开发模板
What if win10 cannot find the flight mode switch?