Data must be serialized before being written

Data is unserialized by redis engine on read, so we have to serialized
on write.
This commit is contained in:
mark_story 2015-08-09 16:00:44 -04:00
parent d6251eff19
commit 67585d6fe1

View file

@ -239,6 +239,10 @@ class RedisEngine extends CacheEngine {
* @link https://github.com/phpredis/phpredis#setnx * @link https://github.com/phpredis/phpredis#setnx
*/ */
public function add($key, $value, $duration) { public function add($key, $value, $duration) {
if (!is_int($value)) {
$value = serialize($value);
}
$result = $this->_Redis->setnx($key, $value); $result = $this->_Redis->setnx($key, $value);
// setnx() doesn't have an expiry option, so overwrite the key with one // setnx() doesn't have an expiry option, so overwrite the key with one
if ($result) { if ($result) {