Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.3

Request #5495 should support eternal caching
Submitted: 2005-09-22 14:04 UTC
From: anarcat at anarcat dot ath dot cx Assigned: fab
Status: Closed Package: Cache_Lite
PHP Version: 4.3.10 OS: Debian GNU/Linux
Roadmaps: (Not assigned)    
Subscription  


 [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; + } } /**

Comments

 [2005-09-22 16:35 UTC] anarcat at anarcat dot ath dot cx
 [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.