cvs: pear /Cache_Lite Lite.php
| From: | Fabien MARTY | Date: | Wed, 16 Nov 2005 22:39:58 +0000 |
| Subject: | cvs: pear /Cache_Lite Lite.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-36338@lists.php.net to get a copy of this message | ||
fab Wed Nov 16 17:39:58 2005 EDT
Modified files:
/pear/Cache_Lite Lite.php
Log:
request #5495 : a null lifetime give an eternal caching (need tests)
http://cvs.php.net/diff.php/pear/Cache_Lite/Lite.php?r1=1.34&r2=1.35&ty=u
Index: pear/Cache_Lite/Lite.php
diff -u pear/Cache_Lite/Lite.php:1.34 pear/Cache_Lite/Lite.php:1.35
--- pear/Cache_Lite/Lite.php:1.34 Wed Nov 16 17:02:11 2005
+++ pear/Cache_Lite/Lite.php Wed Nov 16 17:39:53 2005
@@ -19,7 +19,7 @@
*
* @package Cache_Lite
* @category Caching
-* @version $Id: Lite.php,v 1.34 2005/11/16 22:02:11 fab Exp $
+* @version $Id: Lite.php,v 1.35 2005/11/16 22:39:53 fab Exp $
* @author Fabien MARTY <fab@php.net>
*/
@@ -51,6 +51,8 @@
/**
* Cache lifetime (in seconds)
*
+ * If null, the cache is valid forever.
+ *
* @var int $_lifeTime
*/
var $_lifeTime = 3600;
@@ -267,7 +269,7 @@
foreach($options as $key => $value) {
$this->setOption($key, $value);
}
- $this->_refreshTime = time() - $this->_lifeTime;
+ $this->setLifeTime($options['lifeTime']);
}
/**
@@ -321,7 +323,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();
}
}
@@ -442,7 +444,11 @@
function setLifeTime($newLifeTime)
{
$this->_lifeTime = $newLifeTime;
- $this->_refreshTime = time() - $newLifeTime;
+ if (is_null($newLifeTime)) {
+ $this->refreshTime = null;
+ } else {
+ $this->_refreshTime = time() - $newLifeTime;
+ }
}
/**