diff options
| author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-05 14:59:26 +0000 | 
|---|---|---|
| committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-05 14:59:26 +0000 | 
| commit | 685ade6f02f607200e0b92d6f09abc4a5814e386 (patch) | |
| tree | 8ea5b57264f01a4bb687581d04d91e6aa5b9a2d9 /engine/lib/cache.php | |
| parent | 35f824f7a0c9049e743864b267ef78d8a4d3c0f2 (diff) | |
| download | elgg-685ade6f02f607200e0b92d6f09abc4a5814e386.tar.gz elgg-685ade6f02f607200e0b92d6f09abc4a5814e386.tar.bz2  | |
Added "add" method to cache only if it doesn't exist already.
git-svn-id: https://code.elgg.org/elgg/trunk@2404 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/cache.php')
| -rw-r--r-- | engine/lib/cache.php | 19 | 
1 files changed, 18 insertions, 1 deletions
diff --git a/engine/lib/cache.php b/engine/lib/cache.php index fa5f990df..e8b996e59 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -127,6 +127,23 @@  		 */  		abstract public function clear(); +		/** +		 * Add a key only if it doesn't already exist.  +		 * Implemented simply here, if you extend this class and your caching engine provides a better way then  +		 * override this accordingly. +		 * +		 * @param string $key +		 * @param string $data +		 * @return bool +		 */ +		public function add($key, $data) +		{ +			if (!isset($this[$key]))  +				return $this->save($key, $data); +				 +			return false; +		} +		  		// ARRAY ACCESS INTERFACE //////////////////////////////////////////////////////////  		function offsetSet($key, $value)  		{ @@ -388,7 +405,7 @@  	/** -	 * A simple function that selects the default caching engine.  +	 * A simple function that selects the default memory caching engine.   	 *   	 * This function provides a central way to get a cache for storing local variables.  	 *   | 
