<?php //连接本地的 Redis 服务 $redis = new Redis(); $redis->connect('127.0.0.1', 6379); //设置 redis 字符串数据 $redis->set("tutorial-name", "Redis tutorial"); /**
* 主要是这段代码 * curPage 当前页数 * pageSize 每页展示几条 */ $start = ($curPage - 1) * $pageSize; $stop = $start + ($pageSize - 1); $key = 'test_'; $redis->zRevRange($key,$start, $stop, true) ?>
分页 有序集合的分段
第1页 展示10条 =》 0,9
第2页 展示10条 =》 10,19
第3页 展示10条 =》 20,29