@@ -21,77 +21,77 @@ |
||
| 21 | 21 | { |
| 22 | 22 | var $_bufferedLifetime; |
| 23 | 23 | |
| 24 | - // --- Public methods ---- |
|
| 24 | + // --- Public methods ---- |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Constructor |
|
| 28 | - * |
|
| 29 | - * $options is an assoc. To have a look at availables options, |
|
| 30 | - * see the constructor of the Cache_Lite class in 'Cache_Lite.php' |
|
| 31 | - * |
|
| 32 | - * @param array $options options |
|
| 33 | - * @access public |
|
| 34 | - */ |
|
| 35 | - function __construct($options = array(NULL)) |
|
| 36 | - { |
|
| 37 | - parent::__construct($options); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * Constructor |
|
| 28 | + * |
|
| 29 | + * $options is an assoc. To have a look at availables options, |
|
| 30 | + * see the constructor of the Cache_Lite class in 'Cache_Lite.php' |
|
| 31 | + * |
|
| 32 | + * @param array $options options |
|
| 33 | + * @access public |
|
| 34 | + */ |
|
| 35 | + function __construct($options = array(NULL)) |
|
| 36 | + { |
|
| 37 | + parent::__construct($options); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Save some data in a cache file |
|
| 42 | - * |
|
| 43 | - * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on) |
|
| 44 | - * @param string $id cache id |
|
| 45 | - * @param string $group name of the cache group |
|
| 46 | - * @param int $lifetime The time in seconds that this entry should live. Defaults to the lifetime |
|
| 47 | - * set by the constructor. |
|
| 48 | - * @return boolean true if no problem (else : false or a PEAR_Error object) |
|
| 49 | - * @access public |
|
| 50 | - */ |
|
| 51 | - function save($data, $id = NULL, $group = 'default', $lifetime = null) |
|
| 52 | - { |
|
| 53 | - $res = parent::save($data, $id, $group); |
|
| 54 | - if ($res === true) { |
|
| 55 | - if ($lifetime == null) { |
|
| 56 | - $lifetime = $this->_bufferedLifetime; |
|
| 57 | - } |
|
| 58 | - if ($lifetime == null) { |
|
| 59 | - $lifetime = $this->_lifeTime; |
|
| 60 | - } |
|
| 61 | - $res = $this->_setLastModified(time() + $lifetime); |
|
| 62 | - if (is_object($res)) { |
|
| 63 | - // $res is a PEAR_Error object |
|
| 64 | - if (!($this->_errorHandlingAPIBreak)) { |
|
| 65 | - return false; // we return false (old API) |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - return $res; |
|
| 70 | - } |
|
| 40 | + /** |
|
| 41 | + * Save some data in a cache file |
|
| 42 | + * |
|
| 43 | + * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on) |
|
| 44 | + * @param string $id cache id |
|
| 45 | + * @param string $group name of the cache group |
|
| 46 | + * @param int $lifetime The time in seconds that this entry should live. Defaults to the lifetime |
|
| 47 | + * set by the constructor. |
|
| 48 | + * @return boolean true if no problem (else : false or a PEAR_Error object) |
|
| 49 | + * @access public |
|
| 50 | + */ |
|
| 51 | + function save($data, $id = NULL, $group = 'default', $lifetime = null) |
|
| 52 | + { |
|
| 53 | + $res = parent::save($data, $id, $group); |
|
| 54 | + if ($res === true) { |
|
| 55 | + if ($lifetime == null) { |
|
| 56 | + $lifetime = $this->_bufferedLifetime; |
|
| 57 | + } |
|
| 58 | + if ($lifetime == null) { |
|
| 59 | + $lifetime = $this->_lifeTime; |
|
| 60 | + } |
|
| 61 | + $res = $this->_setLastModified(time() + $lifetime); |
|
| 62 | + if (is_object($res)) { |
|
| 63 | + // $res is a PEAR_Error object |
|
| 64 | + if (!($this->_errorHandlingAPIBreak)) { |
|
| 65 | + return false; // we return false (old API) |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + return $res; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Sets the ctime/mtime status for a file for the given time. |
|
| 74 | - * |
|
| 75 | - * @param integer $time Unix timestamp |
|
| 76 | - * @return boolean |
|
| 77 | - */ |
|
| 78 | - function _setLastModified($time) { |
|
| 79 | - if (@touch($this->_file, $time, $time) === false) { |
|
| 72 | + /** |
|
| 73 | + * Sets the ctime/mtime status for a file for the given time. |
|
| 74 | + * |
|
| 75 | + * @param integer $time Unix timestamp |
|
| 76 | + * @return boolean |
|
| 77 | + */ |
|
| 78 | + function _setLastModified($time) { |
|
| 79 | + if (@touch($this->_file, $time, $time) === false) { |
|
| 80 | 80 | return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1); |
| 81 | - } |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 81 | + } |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Override refresh time function. Returns current time. |
|
| 87 | - * |
|
| 88 | - */ |
|
| 89 | - function _setRefreshTime() { |
|
| 90 | - if (is_null($this->_lifeTime)) { |
|
| 91 | - $this->_refreshTime = null; |
|
| 92 | - } else { |
|
| 93 | - $this->_refreshTime = time(); |
|
| 94 | - } |
|
| 95 | - } |
|
| 85 | + /** |
|
| 86 | + * Override refresh time function. Returns current time. |
|
| 87 | + * |
|
| 88 | + */ |
|
| 89 | + function _setRefreshTime() { |
|
| 90 | + if (is_null($this->_lifeTime)) { |
|
| 91 | + $this->_refreshTime = null; |
|
| 92 | + } else { |
|
| 93 | + $this->_refreshTime = time(); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | } |