Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #642 from DaSourcerer/issue-641

Issue 641
  • Loading branch information...
commit c298fa8a5eb2cc13b6e9fd7137bed87273c18f85 2 parents 0c65972 + c17117d
@samdark samdark authored
Showing with 16 additions and 2 deletions.
  1. +1 −0  CHANGELOG
  2. +15 −2 framework/caching/CCache.php
View
1  CHANGELOG
@@ -30,6 +30,7 @@ Version 1.1.11 work in progress
- Enh #568: CHtml::getIdByName() will now convert spaces to underscore to get proper ID for HTML elements (mdomba)
- Enh #599: Added case sensitivity check when autoloading classes (qiangxue)
- Enh #601: added the method loginRequired() to the IWebUser interface (mdomba)
+- Enh #641: Added support for cache entry serialization through the igbinary serializer (DaSourcerer)
- Enh: Added default value to CConsoleCommand::confirm (musterknabe)
- Enh: Added third parameter to CHttpCookie to configure the cookie by array (suralc)
- Enh: Added getIsFlashRequest(), proper handling of Flash/Flex request when using CWebLogRoute with FireBug (resurtm)
View
17 framework/caching/CCache.php
@@ -78,6 +78,12 @@
**/
public $autoSerialize=true;
+ /**
+ * @var boolean wether to make use of the {@link http://pecl.php.net/package/igbinary igbinary} serializer for cache entry serialization. Defaults to false.
+ * @since 1.1.11
+ */
+ public $useIgbinarySerializer=false;
+
/**
* Initializes the application component.
* This method overrides the parent implementation by setting default cache key prefix.
@@ -87,6 +93,7 @@ public function init()
parent::init();
if($this->keyPrefix===null)
$this->keyPrefix=Yii::app()->getId();
+ $this->useIgbinarySerializer=$this->useIgbinarySerializer&&extension_loaded('igbinary');
}
/**
@@ -311,7 +318,8 @@ protected function flushValues()
/**
* Serializes the value before it will be stored in the actual cache backend.
* This method will be called if {@link autoSerialize} is set to true. Child classes may override this method to change
- * the way the value is being serialized. The default implementation simply makes use of the PHP serialize() function.
+ * the way the value is being serialized. The default implementation simply makes use of the PHP serialize() function
+ * unless {@link useIgbinarySerializer} is set to true and the igbinary extension is installed.
* Make sure to override {@link unserializeValue()} as well if you want to change the serialization process.
* @param mixed $value the unserialized representation of the value
* @return string the serialized representation of the value
@@ -319,13 +327,16 @@ protected function flushValues()
**/
protected function serializeValue($value)
{
+ if($this->useIgbinarySerializer)
+ return igbinary_serialize($value);
return serialize($value);
}
/**
* Unserializes the value after it was retrieved from the actual cache backend.
* This method will be called if {@link autoSerialize} is set to true. Child classes may override this method to change
- * the way the value is being unserialized. The default implementation simply makes use of the PHP unserialize() function.
+ * the way the value is being unserialized. The default implementation simply makes use of the PHP unserialize() function
+ * unless {@link useIgbinarySerializer} is set to true and the igbinary extension is installed.
* Make sure to override {@link serializeValue()} as well if you want to change the serialization process.
* @param string $value the serialized representation of the value
* @return mixed the unserialized representation of the value
@@ -333,6 +344,8 @@ protected function serializeValue($value)
**/
protected function unserializeValue($value)
{
+ if($this->useIgbinarySerializer)
+ return igbinary_unserialize($value);
return unserialize($value);
}
Please sign in to comment.
Something went wrong with that request. Please try again.