Zend_Paginator 和缓存.如何读取已发送到缓存的数据 [英] Zend_Paginator and cache. How can I read the datas that I have sent to cache
问题描述
我将数据注册到缓存,然后看到以下内容:
I register the data to cache and I see the foliowing :
zend_cache---Zend_Paginator_1_42242d5fa3c4e4b7758810c276163e8a
zend_cache---Zend_Paginator_1_42242d5fa3c4e4b7758810c276163e8a
但我看不懂.
$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);
推荐答案
检查是否启用了 DB Profiler.似乎 DB 分析器和 Zend_Paginator_Adapter_DbTableSelect 之间存在冲突.
Check to see if DB profiler is enabled. It seems that there is a conflict between DB profiler and Zend_Paginator_Adapter_DbTableSelect.
我还创建了一个扩展 Zend_Paginator 的新分页器类,并且我修改了 getItemsByPage 函数.
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());
这两行代码应该在开头添加,在$pageNumber = $this->normalizePageNumber($pageNumber)
之后.
These two lines of code should be added at the beggining, after $pageNumber = $this->normalizePageNumber($pageNumber)
.
这篇关于Zend_Paginator 和缓存.如何读取已发送到缓存的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!