summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authoralban <>2006-02-13 15:44:12 +0000
committeralban <>2006-02-13 15:44:12 +0000
commitb24ba1d92683a609a614fe915d3424cbbf854052 (patch)
treee79e843c6608246485634edb46af461f38e6df91 /framework
parent934069ca2164753f72783eaa7d9fd98e4280f2ec (diff)
Let apc serialize object, to have atomic operation.
The downside, is that all value are convertued to ArrayObject to handle object inside the array to be serialized.
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/TAPCCache.php46
1 files changed, 3 insertions, 43 deletions
diff --git a/framework/Data/TAPCCache.php b/framework/Data/TAPCCache.php
index c6b8deb4..cef684fb 100644
--- a/framework/Data/TAPCCache.php
+++ b/framework/Data/TAPCCache.php
@@ -102,10 +102,7 @@ class TAPCCache extends TModule implements ICache
*/
public function get($key)
{
- $ret=apc_fetch($this->_prefix.$key);
- if((boolean)apc_fetch($this->_prefix.$key.self::SERIALIZED))
- $ret=unserialize($ret);
- return $ret;
+ return apc_fetch($this->_prefix.$key);
}
/**
@@ -121,10 +118,8 @@ class TAPCCache extends TModule implements ICache
*/
public function set($key,$value,$expiry=0)
{
- if(!is_string($value)) {
- $value=serialize($value);
- apc_store($this->_prefix.$key.self::SERIALIZED,1,$expiry);
- }
+ if(is_array($value))
+ $value=new ArrayObject($value);
return apc_store($this->_prefix.$key,$value,$expiry);
}
@@ -167,7 +162,6 @@ class TAPCCache extends TModule implements ICache
*/
public function delete($key)
{
- apc_delete($this->_prefix.$key.self::SERIALIZED);
return apc_delete($this->_prefix.$key);
}
@@ -178,40 +172,6 @@ class TAPCCache extends TModule implements ICache
{
return apc_clear_cache('user');
}
-
-
-
- /**
- * Retrieves a value from cache with a specified key.
- * Does not check wether to unserialized
- * @return mixed the value stored in cache, false if the value is not in the cache or expired.
- */
- public function getRaw($key)
- {
- return apc_fetch($this->_prefix.$key);
- }
-
- /**
- * 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.
- *
- * will only serialized pure object, not array, if your array contains object, you need to call {@link set}
- *
- * @param string the key identifying the value to be cached
- * @param mixed the value to be cached
- * @param integer the expiration time of the value,
- * 0 means never expire,
- * @return boolean true if the value is successfully stored into cache, false otherwise
- */
- public function setRaw($key,$value,$expiry=0)
- {
- if(is_object($value)) {
- $value=serialize($value);
- apc_store($this->_prefix.$key.self::SERIALIZED,1,$expiry);
- }
- return apc_store($this->_prefix.$key,$value,$expiry);
- }
}