Zend Cache issue

For programming and general questions on Zend Framework

Zend Cache issue

Postby shritesha on Fri Feb 01, 2013 7:55 am

Hi,

I am using following code for Zend Front End cache. It is not working as expected. Can anyone please look and let me know if anything needs to be done?

Expected Output: Cache the pages for 12 Hrs.

protected function _initCache()
{
$frontendOptions = array
(
'lifetime' => CFG_CACHE_LIFETIME_IN_SECONDS,
'automatic_serialization' => true,
'default_options' => array
(
'cache_with_get_variables' => true,
'cache_with_post_variables' => true,
'cache_with_session_variables' => true,
'cache_with_files_variables' => true,
'cache_with_cookie_variables' => true,
'make_id_with_get_variables' => true,
'make_id_with_post_variables' => true,
'make_id_with_session_variables' => true,
'make_id_with_files_variables' => true,
'make_id_with_cookie_variables' => true,
'cache'=>true
),
);
$backendOptions = array
(
'cache_dir' => APPLICATION_PATH . '/../cache/'
);
$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
$cache->start();
Zend_Registry::set('objCache',$cache);
}
shritesha
 
Posts: 2
Joined: Fri Feb 01, 2013 7:53 am

Re: Zend Cache issue

Postby shritesha on Tue Mar 12, 2013 8:54 am

Adding more info:

The above code does do caching, but it is bound with Session. i.e with different browsers it cache with different ID.

e.g
Browser1 Home Page Cache ID: zend_cache---2c0cdc2f143d4db2916aace1f2d1c65e
Browser1 Home Page Cache ID: zend_cache---3fdd360133ace8d64e98769fd053e239

I want this to work as a shared cache. Multiple users/Browser session should access same cache. One cache ID for single page.
shritesha
 
Posts: 2
Joined: Fri Feb 01, 2013 7:53 am

Re: Zend Cache issue

Postby tedtiger on Wed Mar 13, 2013 7:43 am

Code: Select all
$ozf_scache = Zend_Cache::factory( 'Core', 'File', array(
      'lifetime' => null,
      'automatic_serialization' => true,
      'cache_id_prefix' => 'SessionCache'
), array(
      'cache_dir' => "/tmp/",
      'file_name_prefix' => 'CommonCache',
      'cache_file_perm' => 0777
) );
$ozf_scache->clean(Zend_Cache::CLEANING_MODE_OLD);

$ozf_scache->save($data, 'useAlwaysSameCacheID');

$ozf_scache->load('useAlwaysSameCacheID');


Using the same CacheID should do the trick.
tedtiger
 
Posts: 169
Joined: Thu Mar 05, 2009 4:59 pm
Location: Germany


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 8 guests