summaryrefslogtreecommitdiff
path: root/framework/Caching
diff options
context:
space:
mode:
authorchristophe.boulain <>2008-12-03 14:22:03 +0000
committerchristophe.boulain <>2008-12-03 14:22:03 +0000
commit6228873cf9d6471463d2413e7dfd7447f759baf2 (patch)
tree496a0e658330c39d4caa35602ba9f783b6f24f9c /framework/Caching
parente8f239fea7351b248302a593a8e5eaa2a88c3e80 (diff)
Merge from trunk
Diffstat (limited to 'framework/Caching')
-rw-r--r--framework/Caching/TAPCCache.php1
-rw-r--r--framework/Caching/TCache.php20
-rw-r--r--framework/Caching/TMemCache.php1
-rw-r--r--framework/Caching/TSqliteCache.php1
4 files changed, 14 insertions, 9 deletions
diff --git a/framework/Caching/TAPCCache.php b/framework/Caching/TAPCCache.php
index 057d7585..5935e732 100644
--- a/framework/Caching/TAPCCache.php
+++ b/framework/Caching/TAPCCache.php
@@ -131,4 +131,3 @@ class TAPCCache extends TCache
}
}
-?>
diff --git a/framework/Caching/TCache.php b/framework/Caching/TCache.php
index 27618e84..02a4ae3b 100644
--- a/framework/Caching/TCache.php
+++ b/framework/Caching/TCache.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Caching
@@ -136,7 +136,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
/**
* Stores a value identified by a key into cache.
* If the cache already contains such a key, the existing value and
- * expiration time will be replaced with the new ones.
+ * expiration time will be replaced with the new ones. If the value is
+ * empty, the cache key will be deleted.
*
* @param string the key identifying the value to be cached
* @param mixed the value to be cached
@@ -146,13 +147,18 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
*/
public function set($id,$value,$expire=0,$dependency=null)
{
- $data=array($value,$dependency);
- return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire);
+ if(empty($value) && $expire === 0)
+ $this->delete($id);
+ else
+ {
+ $data=array($value,$dependency);
+ return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire);
+ }
}
/**
* Stores a value identified by a key into cache if the cache does not contain this key.
- * Nothing will be done if the cache already contains the key.
+ * Nothing will be done if the cache already contains the key or if value is empty.
* @param string the key identifying the value to be cached
* @param mixed the value to be cached
* @param integer the number of seconds in which the cached value will expire. 0 means never expire.
@@ -161,6 +167,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
*/
public function add($id,$value,$expire=0,$dependency=null)
{
+ if(empty($value) && $expire === 0)
+ return false;
$data=array($value,$dependency);
return $this->addValue($this->generateUniqueKey($id),serialize($data),$expire);
}
@@ -710,4 +718,4 @@ class TCacheDependencyList extends TList
}
}
-?>
+?>
diff --git a/framework/Caching/TMemCache.php b/framework/Caching/TMemCache.php
index b6e9c7d8..0f0ac26d 100644
--- a/framework/Caching/TMemCache.php
+++ b/framework/Caching/TMemCache.php
@@ -307,4 +307,3 @@ class TMemCache extends TCache
}
}
-?>
diff --git a/framework/Caching/TSqliteCache.php b/framework/Caching/TSqliteCache.php
index 4d41542c..ca8d2261 100644
--- a/framework/Caching/TSqliteCache.php
+++ b/framework/Caching/TSqliteCache.php
@@ -221,4 +221,3 @@ class TSqliteCache extends TCache
}
}
-?>