Skip to content

Commit

Permalink
[mms] Fix lifetime usage in the file driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Jan 24, 2014
1 parent 0fb3230 commit 3967adc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 4 additions & 8 deletions framework/Cache/lib/Horde/Cache/Storage/File.php
Expand Up @@ -91,12 +91,8 @@ public function __destruct()
}

foreach ($this->_getCacheFiles() as $fname => $pname) {
$d_time = isset($excepts[$fname])
? $excepts[$fname]
: $this->_params['lifetime'];

if (!empty($d_time) &&
(($c_time - $d_time) > filemtime($pname))) {
if (!empty($excepts[$fname]) &&
(($c_time - $excepts[$fname]) > filemtime($pname))) {
@unlink($pname);
unset($excepts[$fname]);
}
Expand Down Expand Up @@ -143,12 +139,12 @@ public function set($key, $data, $lifetime = 0)

@rename($tmp_file, $filename);

if (($lifetime != $this->_params['lifetime']) &&
if ($lifetime &&
($fp = @fopen($this->_params['dir'] . '/' . self::GC_FILE, 'a'))) {
// This may result in duplicate entries in GC_FILE, but we
// will take care of these whenever we do GC and this is quicker
// than having to check every time we access the file.
fwrite($fp, $filename . "\t" . (empty($lifetime) ? 0 : time() + $lifetime) . "\n");
fwrite($fp, $filename . "\t" . (time() + $lifetime) . "\n");
fclose($fp);
}
}
Expand Down
2 changes: 2 additions & 0 deletions framework/Cache/package.xml
Expand Up @@ -27,6 +27,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Fix lifetime usage in the file driver.
* [mms] Add &apos;no_gc&apos; parameter to the Horde_Cache_Storage_File driver.
</notes>
<contents>
Expand Down Expand Up @@ -532,6 +533,7 @@ Initial packaging.
<date>2013-10-08</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Fix lifetime usage in the file driver.
* [mms] Add &apos;no_gc&apos; parameter to the Horde_Cache_Storage_File driver.
</notes>
</release>
Expand Down

0 comments on commit 3967adc

Please sign in to comment.