From 67585d6fe1561dcee979fc9315d03b2ec9bd7384 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 9 Aug 2015 16:00:44 -0400 Subject: [PATCH] Data must be serialized before being written Data is unserialized by redis engine on read, so we have to serialized on write. --- lib/Cake/Cache/Engine/RedisEngine.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Cache/Engine/RedisEngine.php b/lib/Cake/Cache/Engine/RedisEngine.php index bf735d26a..b8bdd4c0d 100644 --- a/lib/Cake/Cache/Engine/RedisEngine.php +++ b/lib/Cake/Cache/Engine/RedisEngine.php @@ -239,6 +239,10 @@ class RedisEngine extends CacheEngine { * @link https://github.com/phpredis/phpredis#setnx */ public function add($key, $value, $duration) { + if (!is_int($value)) { + $value = serialize($value); + } + $result = $this->_Redis->setnx($key, $value); // setnx() doesn't have an expiry option, so overwrite the key with one if ($result) {