Skip to content

Commit

Permalink
Data must be serialized before being written
Browse files Browse the repository at this point in the history
Data is unserialized by redis engine on read, so we have to serialized
on write.
  • Loading branch information
markstory committed Aug 9, 2015
1 parent d6251ef commit 67585d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -239,6 +239,10 @@ public function __destruct() {
* @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) {
Expand Down

0 comments on commit 67585d6

Please sign in to comment.