Zend Framework

Zend_Cache_Backend_File use glob() to find cache files ?

Details

  • Type: Patch Patch
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9.2
  • Fix Version/s: 1.5.0
  • Component/s: Zend_Cache
  • Labels:
    None

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

  1. File2.php
    01/Jun/07 5:49 PM
    17 kB
    Marc Bennewitz (GIATA mbH)
  2. File2.php
    31/May/07 4:43 PM
    17 kB
    Marc Bennewitz (GIATA mbH)
  3. File2.php
    31/May/07 4:39 PM
    18 kB
    Marc Bennewitz (GIATA mbH)
  4. File2.php
    31/May/07 4:35 PM
    18 kB
    Marc Bennewitz (GIATA mbH)

Issue Links

Activity

Hide
Thomas Weidner added a comment -

Zend_Cache related issue, assigned to Fabien

Show
Thomas Weidner added a comment - Zend_Cache related issue, assigned to Fabien
Hide
Fabien MARTY added a comment -

> 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 ?

Show
Fabien MARTY added a comment - > 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 ?
Hide
Fabien MARTY added a comment -

particulary when you do a clean with CLEANING_MODE_OLD

Show
Fabien MARTY added a comment - particulary when you do a clean with CLEANING_MODE_OLD
Hide
Marc Bennewitz (GIATA mbH) added a comment -

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.

Show
Marc Bennewitz (GIATA mbH) added a comment - 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.
Hide
Marc Bennewitz (GIATA mbH) added a comment -

new version

Show
Marc Bennewitz (GIATA mbH) added a comment - new version
Hide
Marc Bennewitz (GIATA mbH) added a comment -

new version

Show
Marc Bennewitz (GIATA mbH) added a comment - new version
Hide
Marc Bennewitz (GIATA mbH) added a comment -

new version

I write tags as serialized string a cache file named "<cache id>.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 "<cache id>.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

Show
Marc Bennewitz (GIATA mbH) added a comment - new version I write tags as serialized string a cache file named "<cache id>.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 "<cache id>.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
Hide
Fabien MARTY added a comment -

thanks, I will review it after 1.0.0

Show
Fabien MARTY added a comment - thanks, I will review it after 1.0.0
Hide
Fabien MARTY added a comment -

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

many thanks

Show
Fabien MARTY added a comment - I just commited a completely new file backend inspired by your ideas and your code many thanks

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: