Zend_Paginator and cache. How can I read the datas

2019-05-18 03:55发布

问题:

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).