From 750ab8b5a8814295a4774612cc4f9c727d316fe3 Mon Sep 17 00:00:00 2001 From: alban <> Date: Mon, 6 Feb 2006 10:17:50 +0000 Subject: added getRaw and setRaw method, if you need to store/retrieve value which are not object, and do not need to serialize. Prado need the Cache to deal with serialization due to implementation, perhaps it should be a responsability to prado to (un/)serialized object prior to call the caching module ? So get/setRaw method will allow user to store mainly array wihtout bothering and addind overhead due to serialization. setRaw still test for is_object to deal with serialization. --- framework/Data/TAPCCache.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'framework') diff --git a/framework/Data/TAPCCache.php b/framework/Data/TAPCCache.php index cdd8f5f1..c6b8deb4 100644 --- a/framework/Data/TAPCCache.php +++ b/framework/Data/TAPCCache.php @@ -178,6 +178,40 @@ 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); + } } -- cgit v1.2.3