I use Cache::read()
, Cache::write()
in CakePhp to cache queries.
How to update paginator params or CACHE whole paginator?
It easy to cache query result but how to cache $this->Paginator->params()
too?
I've tried to Cache::write()
$this->Paginator->params()
but how to modify $this->Paginator->params()
after caching? When I do someting like:
...
$this->Paginator->params['paging'][$model] = $paginator_params;
... I've got notice:
Indirect modification of overloaded element of CakeRequest has no effect
Where and when I can rewrite PAGINATOR params/set cached params?
Thanks.
You need to cache
$this->request->params['paging']
array.And you have to add Paginator Helper to
$helpers
array. If you don't, beforeRender method of Paginator helper won't be invoked and paging links will be broken.If anyone's come here looking for a CakePHP 2.5+ version of this, the following should work well, using Cache::remember:
You'll have an array, $products, which you can set onto your view for rendering.