Serializer
You can specify serialize method with serializerAdapter option:
- phpSerialize - standart PHP serializer (function serialize). This method is used by default
- json - No comments
- toString - Casts value to string ((string)$value)
<?php $options = array( 'serializerAdapter' => 'json', ); $rediska = new Rediska($options); ?>
You can use your own serializer with Rediska. You just need to create a class implementing Rediska_Serializer_Adapter_Interface interface:
<?php class MySerializerAdapter implements Rediska_Serializer_Adapter_Interface { public function serialize($value) { return mySerializeMethod($value); } public function unserialize($value) { $value = myUnserializeMethod($value); // You must throw exception if you can't unserialize string becouse serialized only objects and arrays if (unserializeError()) { throw new Rediska_Serializer_Adapter_Exception("Can't unserialize value"); } } } $options = array( 'serializerAdapter' => 'MySerializerAdapter', ); $rediska = new Rediska($options); ?>