ZF-1295: Zend_Cache_Backend_File use glob() to find cache files ?
Description
Exist a particular reason to save expire timestamp in the cache file name ? If not the system must not search cached file
private function _file($id, $expire = null)
{
$path = $this->_path($id);
if (is_null($expire)) {
$glob = @glob($path . $this->_idToFileName($id, '*')); //??????????????????
$nbr = count($glob);
if ($nbr == 1) {
return $glob[0];
}
return null;
}
$fileName = $this->_idToFileName($id, $expire);
return $path . $fileName;
}
and on load a cache id this method will call on test expire date and on read file
It is superior to write the expire timestamp as first byte in the file -> better performance on test read only the first byte and unpack this to a integer and on load the opened file must not close after testing expire date
Comments
Posted by Thomas Weidner (thomas) on 2007-05-06T09:27:50.000+0000
Zend_Cache related issue, assigned to Fabien
Posted by Fabien MARTY (fab) on 2007-05-08T08:00:10.000+0000
Are you sure about it ? Do you make some benchs ?
Posted by Fabien MARTY (fab) on 2007-05-08T08:03:09.000+0000
particulary when you do a clean with CLEANING_MODE_OLD
Posted by Marc Bennewitz (GIATA mbH) (mben) on 2007-05-31T16:35:52.000+0000
I have rewritten the class Zend_Cache_Backend_File but it is not tested yet. testing and bench comming soon
This class should fix ZF-1338, too.
Posted by Marc Bennewitz (GIATA mbH) (mben) on 2007-05-31T16:39:31.000+0000
new version
Posted by Marc Bennewitz (GIATA mbH) (mben) on 2007-05-31T16:43:57.000+0000
new version
Posted by Marc Bennewitz (GIATA mbH) (mben) on 2007-06-01T17:49:44.000+0000
new version
I write tags as serialized string a cache file named ".tag" The expirce time included as the first 4 bytes in the data file. The hash including data file, too (32 bytes after expire only is read control is enabled) The data file is named ".data"
now the tests pass without: testCleanModeOld & testGetWithAnExpiredCacheId this methods using public __expire ????
A very simple bench using tests (only Zend_Cache) like
result is:
my: 2.8983469009399 2.7813038825989 2.7996349334717 2.8102550506592 2.7592458724976
zend: 3.6789040565491 3.5660190582275 3.6374979019165 3.6498610973358 3.5821039676666
Posted by Fabien MARTY (fab) on 2007-06-09T03:00:21.000+0000
thanks, I will review it after 1.0.0
Posted by Fabien MARTY (fab) on 2008-01-17T17:49:20.000+0000
I just commited a completely new file backend inspired by your ideas and your code
many thanks