Zend_Paginator and cache. How can I read the datas that I have sent to cache

别等时光非礼了梦想. 提交于 2019-12-07 15:17:18

问题


I register the data to cache and I see the foliowing :

zend_cache---Zend_Paginator_1_42242d5fa3c4e4b7758810c276163e8a

but I can't read.

$request = $this->getRequest();
 $q = new Model();
 $paginator = Zend_Paginator::factory($q->fetchAll());
 $paginator->setCurrentPageNumber($request->getParam('p')); 
 $paginator->setItemCountPerPage(40);
 $this->view->q = $paginator;

 $fO = array('lifetime' => 3600, 'automatic_serialization' => true);
 $bO = array('cache_dir'=> APPLICATION_PATH . '/cache/');
 $cache = Zend_cache::factory('Core', 'File', $fO, $bO);
 Zend_Paginator::setCache($cache);

回答1:


Check to see if DB profiler is enabled. It seems that there is a conflict between DB profiler and Zend_Paginator_Adapter_DbTableSelect.

I've also created a new Paginator class that extends Zend_Paginator and I've modified getItemsByPage function.

$offset = ($pageNumber - 1) * $this->getItemCountPerPage();
$items = $this->_adapter->getItems($offset, $this->getItemCountPerPage());

These two lines of code should be added at the beggining, after $pageNumber = $this->normalizePageNumber($pageNumber).



来源:https://stackoverflow.com/questions/2152759/zend-paginator-and-cache-how-can-i-read-the-datas-that-i-have-sent-to-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!