Issues

ZF-1295: Zend_Cache_Backend_File use glob() to find cache files ?

Issue Type: Patch Created: 2007-04-19T15:09:08.000+0000 Last Updated: 2008-03-21T16:25:25.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Marc Bennewitz (GIATA mbH) (mben) Assignee: Fabien MARTY (fab) Tags: - Zend_Cache

Related issues: - ZF-2449

Attachments: - File2.php

Description

Exist a particular reason to save expire timestamp in the cache file name ? If not the system must not search cached file

<pre class="highlight">
    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

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 ?

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

<pre class="highlight">
$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

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts