Issues

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

Zend_Cache related issue, assigned to Fabien

It is superior to write the expire timestamp as first byte in the file -> better performance

Are you sure about it ? Do you make some benchs ?

particulary when you do a clean with CLEANING_MODE_OLD

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.

new version

new version

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


$start = microtime(true);
for ($i=0; $i<10; $i++) {
  AllTests::main();
}
echo "\n\nStart: $start\n";
echo "End:".($end=microtime(true))."\n";
echo ($end-$start)."\n";

result is:

my: 2.8983469009399 2.7813038825989 2.7996349334717 2.8102550506592 2.7592458724976

zend: 3.6789040565491 3.5660190582275 3.6374979019165 3.6498610973358 3.5821039676666

thanks, I will review it after 1.0.0

I just commited a completely new file backend inspired by your ideas and your code

many thanks