diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index 78ec45ba6..2faa5a9ee 100644 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -99,6 +99,10 @@ class RedisCache extends ConnectionAbstract throw new \InvalidArgumentException(); } + if (\is_bool($value)) { + $value = $value ? 'true' : 'false'; + } + if ($expire > 0) { $this->con->set($key, $value, $expire); } @@ -115,10 +119,16 @@ class RedisCache extends ConnectionAbstract return false; } + // todo: pull out if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) { throw new \InvalidArgumentException(); } + // todo: pull out + if (\is_bool($value)) { + $value = $value ? 'true' : 'false'; + } + if ($expire > 0) { return $this->con->setNx($key, $value, $expire); } @@ -137,6 +147,12 @@ class RedisCache extends ConnectionAbstract $result = $this->con->get($key); + if ($result === 'true') { + $result = true; + } elseif ($result === 'false') { + $result = false; + } + return $result; }