Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:57:12+00:00 2026-06-10T18:57:12+00:00

I use a file based cache to cache a paginator: $table = $this->getDbTable(); $ret

  • 0

I use a file based cache to cache a paginator:

$table = $this->getDbTable();

$ret = $table   ->select()
        ->from($table,array('id',
                            'UNIX_TIMESTAMP(`date`) as date',
                            'categoryId',
                            'title',
                            'teaser'))
        ->where('`categoryId`=?',$cat)
        ->order('date desc');

$adapter = new Zend_Paginator_Adapter_DbTableSelect($ret);
$paginator = new Zend_Paginator($adapter);

$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);

$paginator->setItemCountPerPage(5);
$paginator->setCurrentPageNumber($page);

$this->view->paginator = $paginator;

Now every request, the paginator creates a neew cache entry and ignors the old one created? Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:57:14+00:00Added an answer on June 10, 2026 at 6:57 pm

    I had some similar problems with Zend_Paginator. These problems only come with Zend_Paginator_Adapter_DbTableSelect (I had no problems with Zend_Paginator_Adapter_Array).

    The bolded part of the cache filename zend_cache---Zend_Paginator_3_2b49905a9282f742e1cefafc53892794 is made by _getCacheId function (check Zend_Paginator) based on the adapter passed to the constructor. On each request, the paginator creates a new code because the adapter is never the same at the $_cache->load moment and $_cache->save moment.

    The md5 serialized value of the adapter used as filename when data is saved into cache is different from the one used when data is read from cache if you have DB profiler enabled. You must not use DB profiler in order for the Zend_Paginator cache to work (use it only in development stage).

    Another failure reason that I have found is determined by these two lines of code:

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

    They are called between $_cache->load and $_cache->save and they add a limitcount value and a limitoffset value to adapter. This values aren’t set when $_cache->load is called so the filename based on the md5 serialized value of the adapter will be different in this case too.

    They must be placed before $_cache->load. You can make a paginator class that extends Zend_Paginator and modify getItemsByPage function. Add the two lines at the beggining, after $pageNumber = $this->normalizePageNumber($pageNumber).

    This worked for me. I hope it will help others too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most examples use time-based cache expiration. I'd like to read more about file caches
I need to use memcached and file based cache. I setup my cache in
I use the following coding which edits my text file based on the value
Currently in my PHP-based applications I use a file, for instance services.php and call
I changed my .autotest file to use it with a Ruby-based project. After that,
I use (File System Based) static html files for caching, for some reasons i
This is an image based project. In this I want to download image from
I am new to codeigniter. I want to use file-based caching.I don't know if
In Yii, I have enabled APC caching through the config/main.php file: 'cache' => array(
How can I test that resource (file based cache for caching output of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.