summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authoralban <>2006-02-06 10:17:50 +0000
committeralban <>2006-02-06 10:17:50 +0000
commit750ab8b5a8814295a4774612cc4f9c727d316fe3 (patch)
tree4394789f09d7696a8bf7eb52afaa1275814c4770 /framework/Data
parentb2ff418c4f38ee2799bfa6c91618d0e5be666d0e (diff)
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.
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/TAPCCache.php34
1 files changed, 34 insertions, 0 deletions
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);
+ }
}