PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Caching » Cache_Lite » Bug #5495

should support eternal caching

Details

Request #5495should support eternal caching
Submitted2005-09-22 14:04 UTC
Fromanarcat at anarcat dot ath dot cx
Assignedfab
StatusClosed
PackageCache_Lite
PHP Version4.3.10
OSDebian GNU/Linux
Roadmaps(Not assigned)

Comments

[2005-09-22 14:04 UTC] anarcat at anarcat dot ath dot cx

Description:
------------
In the version of PEAR Cache::Lite we have, it is impossible to tell the cache system never to refresh. This is really useful in case of frontend systems that need to cache forever and refresh on-demand.

A patch is attached, for Cache::Lite 1.5.2.

Test script:
---------------
--- Lite.php.orig 2005-09-22 09:59:18.000000000 -0400
+++ Lite.php 2005-09-22 10:01:49.000000000 -0400
@@ -67,6 +67,8 @@
/**
* Timestamp of the last valid cache
*
+ * If null, the cache is valid forever.
+ *
* @var int $_refreshTime
*/
var $_refreshTime;
@@ -271,7 +273,11 @@
$this->$property = $value;
}
}
- $this->_refreshTime = time() - $this->_lifeTime;
+ if (is_null($this->_lifeTime)) {
+ $this->_refreshTime = null;
+ } else {
+ $this->_refreshTime = time() - $this->_lifeTime;
+ }
}

/**
@@ -308,7 +314,7 @@
$data = $this->_read();
}
} else {
- if ((file_exists($this->_file)) && (@filemtime($this->_file) >
$this->_refreshTime)) {
+ if ((file_exists($this->_file)) && (@filemtime($this->_file) >
$this->_refreshTime) && !is_null($this->_refreshTime)) {
$data = $this->_read();
}
}
@@ -429,7 +435,11 @@
function setLifeTime($newLifeTime)
{
$this->_lifeTime = $newLifeTime;
- $this->_refreshTime = time() - $newLifeTime;
+ if (is_null($newLifeTime)) {
+ $this->refreshTime = null;
+ } else {
+ $this->_refreshTime = time() - $newLifeTime;
+ }
}

/**

[2005-09-22 16:35 UTC] anarcat at anarcat dot ath dot cx

If formatting is a problem, you can fetch the patch here:

http://lethe.koumbit.net/cgi-bin/darcs.cgi/tricked/?c=diff&p=20050922140910-d03ae-33e4aa974e2ea3be3ad3749a639d76c2eea61f00.gz

[2005-10-05 18:38 UTC] fab at php dot net

thanks, i will consider this for the next version

[2005-11-16 22:40 UTC] fab at php dot net

This bug has been fixed in CVS.

If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.