Hi,
Please open a bug report.
There is probably a problem with some big changes commited after the
0.7 version.
Regards
2007/2/3, Bartosz Maciaszek <[EMAIL PROTECTED]>:
Hi everyone
Looking for the best solution to cache smarty templates in
ZendFramework I decided to use Zend_Cache (frontend: 'File', backend:
'File'). Everything worked fine until some update around rev 3000.
There's some problem with calculating cache validity time and it
doesn't seem to cache as expected. Cache should be valid until I
change masterfile but it becomes outdated immediately. I use
Zend_Cache as follows:
$frontendOptions = array('masterFile' => 'masterfile.txt');
$backendOptions = array();
$cache = Zend_Cache::factory('File', 'File', $frontendOptions, $backendOptions);
if(!$data = $cache->load('test'))
{
$data = 'foobar ' . time();
$cache->save($data, 'test');
}
echo $data;
I was digging to find out what was wrong and I've found following:
$cache->save points to Zend_Cache_Core::save(). Fourth parameter,
$specificLifeTime, defaults to '-1'. It's passed to backend's save()
around line 288 where it defaults to false and then to getLifeTime():
public function getLifeTime($specificLifeTime)
{
if ($specificLifeTime === false) {
return $this->_directives['lifeTime'];
}
return $specificLifeTime;
}
So, we still have -1.
Then it goes further:
private function _expireTime($lifeTime)
{
if (is_null($this->_directives['lifeTime'])) {
return 9999999999;
}
return time() + $lifeTime;
}
Now, the 'directives' are being checked. I've found that directives
are hardcoded in Cache/Backend/File.php:
protected $_directives = array(
'lifeTime' => 3600,
'logging' => false
);
Actually there's method named setDirectives() in Cache/Backend.php,
but how can I call it when I don't have an object of front- or
backend, I pass their names as strings to Zend_Cache::factory().
Any ideas?
Regards
Bartosz
--
Fabien MARTY
[EMAIL PROTECTED]