翻页使用spCache问题

#1 Seul



http://www.speedphp.com/thread-3798-1-1.html 按照这个手册的操作后

if($price || $procat || $type || $act_from || $q)
                    $itemsTemp = $pros->spPager($page,56)->findAll($where,$order);//$itemsTemp = $pros->spCache(480)->getmypage($where,$order,$page,56);
                else
                    $itemsTemp = $pros->spCache(480)->getmypage($where.' and classification=1',$order,$page,56);//$itemsTemp = $pros->spPager($page,56)->findAll($where.' and classification=1',$order);//这个数据就是首页和标准翻页的数据集
                if(!$procat && !$type && !$price && !$act_from && !$q){
                    $itemsC1 = $pros->spCache(480)->findAll($where.' and classification=2',$order);//$pros->spCache(480)->findAll($where.' and classification=2',$order);
                    $itemsC2 = $pros->spCache(480)->findAll($where.' and classification=3',$order);//$pros->spPager($page,56)->findAll($where,$order);
                }
上面是取数据的代码一共3个分类的数据
function getmypage($conditions,$order, $page, $pageSize){
           return $this->spPager($page,$pageSize)->findAll($conditions,$order);
        }
然后上面的是去页码数据的函数

翻页使用spCache后翻到第二页然后在点首页,$pros->spPager()->getPager();就成空的了,求解啊!


2015-08-13 00:09:13

#2 jake

比较乱,看不明白

建议的做法是分页之后再用spAccess对查询结果缓存,spCache只能针对普通的查询。

2015-08-13 08:28:25

#3 Seul

jake 发表于 2015-8-13 08:28
比较乱,看不明白

建议的做法是分页之后再用spAccess对查询结果缓存,spCache只能针对普通的查询。 ...
我想问下对于大数据比如10w的商品数据怎么做分页缓存,就是每一页都缓存一段时间,这个怎么实现

2015-08-15 23:51:17

#4 Seul

解决了,改装下这个函数就可以了
function getmypage($conditions, $page, $pageSize){
           $result['data'] = $this->spPager($page, $pageSize)->findAll($conditions);
           $result['pager'] = $this->spPager()->getPager();
        }

2015-08-19 18:09:52