From 920f78939adcdb62f5e6ac9368928bd3a0fa41fc Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sat, 16 Jul 2011 22:37:30 +0000 Subject: test patch for #179 --- framework/Caching/TAPCCache.php | 2 +- framework/Caching/TCache.php | 13 ++++++------- framework/Caching/TDbCache.php | 6 +++--- framework/Caching/TSqliteCache.php | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'framework/Caching') diff --git a/framework/Caching/TAPCCache.php b/framework/Caching/TAPCCache.php index 20715d9b..84a79315 100644 --- a/framework/Caching/TAPCCache.php +++ b/framework/Caching/TAPCCache.php @@ -4,7 +4,7 @@ * * @author Alban Hanry * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2011 PradoSoft + * @copyright Copyright © 2005-2011 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Caching diff --git a/framework/Caching/TCache.php b/framework/Caching/TCache.php index 39f3e780..57bdb4db 100644 --- a/framework/Caching/TCache.php +++ b/framework/Caching/TCache.php @@ -122,9 +122,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess */ public function get($id) { - if(($value=$this->getValue($this->generateUniqueKey($id)))!==false) + if(($data=$this->getValue($this->generateUniqueKey($id)))!==false) { - $data=unserialize($value); if(!is_array($data)) return false; if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged()) @@ -152,7 +151,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess else { $data=array($value,$dependency); - return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire); + return $this->setValue($this->generateUniqueKey($id),$data,$expire); } } @@ -170,7 +169,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess if(empty($value) && $expire === 0) return false; $data=array($value,$dependency); - return $this->addValue($this->generateUniqueKey($id),serialize($data),$expire); + return $this->addValue($this->generateUniqueKey($id),$data,$expire); } /** @@ -252,7 +251,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess return $this->get($id) !== false; } - /* + /** * Retrieves the value from cache with a specified key. * This method is required by the interface ArrayAccess. * @param string a key identifying the cached value @@ -263,7 +262,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess return $this->get($id); } - /* + /** * Stores the value identified by a key into cache. * If the cache already contains such a key, the existing value will be * replaced with the new ones. To add expiration and dependencies, use the set() method. @@ -276,7 +275,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess $this->set($id, $value); } - /* + /** * Deletes the value with the specified key from cache * This method is required by the interface ArrayAccess. * @param string the key of the value to be deleted diff --git a/framework/Caching/TDbCache.php b/framework/Caching/TDbCache.php index 9d1793e1..90aa88c6 100644 --- a/framework/Caching/TDbCache.php +++ b/framework/Caching/TDbCache.php @@ -466,12 +466,12 @@ class TDbCache extends TCache try { $sql='SELECT value FROM '.$this->_cacheTable.' WHERE itemkey=\''.$key.'\' AND (expire=0 OR expire>'.time().') ORDER BY expire DESC'; $command=$this->getDbConnection()->createCommand($sql); - return $command->queryScalar(); + return Prado::unserialize($command->queryScalar()); } catch(Exception $e) { $this->initializeCache(true); - return $command->queryScalar(); + return Prado::unserialize($command->queryScalar()); } } @@ -508,7 +508,7 @@ class TDbCache extends TCache { $command=$this->getDbConnection()->createCommand($sql); $command->bindValue(':key',$key,PDO::PARAM_STR); - $command->bindValue(':value',$value,PDO::PARAM_LOB); + $command->bindValue(':value',Prado::serialize($value),PDO::PARAM_LOB); $command->execute(); return true; } diff --git a/framework/Caching/TSqliteCache.php b/framework/Caching/TSqliteCache.php index 4a1aa615..d4308e64 100644 --- a/framework/Caching/TSqliteCache.php +++ b/framework/Caching/TSqliteCache.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2011 PradoSoft + * @copyright Copyright © 2005-2011 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Caching @@ -18,7 +18,7 @@ * To use this module, the sqlite PHP extension must be loaded. Note, Sqlite extension * is no longer loaded by default since PHP 5.1. * - * Sine PRADO v3.1.0, a new DB-based cache module called {@link TDbCache} + * Since PRADO v3.1.0, a new DB-based cache module called {@link TDbCache} * is provided. If you have PDO extension installed, you may consider using * the new cache module instead as it allows you to use different database * to store the cached data. @@ -162,7 +162,7 @@ class TSqliteCache extends TCache { $sql='SELECT value FROM '.self::CACHE_TABLE.' WHERE key=\''.$key.'\' AND (expire=0 OR expire>'.time().') LIMIT 1'; if(($ret=$this->_db->query($sql))!=false && ($row=$ret->fetch(SQLITE_ASSOC))!==false) - return $row['value']; + return Prado::unserialize($row['value']); else return false; } @@ -179,7 +179,7 @@ class TSqliteCache extends TCache protected function setValue($key,$value,$expire) { $expire=($expire<=0)?0:time()+$expire; - $sql='REPLACE INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string($value).'\','.$expire.')'; + $sql='REPLACE INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string(Prado::serialize($value)).'\','.$expire.')'; return $this->_db->query($sql)!==false; } @@ -195,7 +195,7 @@ class TSqliteCache extends TCache protected function addValue($key,$value,$expire) { $expire=($expire<=0)?0:time()+$expire; - $sql='INSERT INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string($value).'\','.$expire.')'; + $sql='INSERT INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string(Prado::serialize($value)).'\','.$expire.')'; return @$this->_db->query($sql)!==false; } -- cgit v1.2.3