Skip to content
Snippets Groups Projects
Commit e25998df authored by Joas Schilling's avatar Joas Schilling
Browse files

Json_(en|de)code values on redis to be able to cache arrays

parent 7eb84040
No related branches found
No related tags found
No related merge requests found
......@@ -49,18 +49,18 @@ class Redis extends Cache {
public function get($key) {
$result = self::$cache->get($this->getNamespace() . $key);
if ($result === false and ! self::$cache->exists($this->getNamespace() . $key)) {
if ($result === false && !self::$cache->exists($this->getNamespace() . $key)) {
return null;
} else {
return $result;
return json_decode($result, true);
}
}
public function set($key, $value, $ttl = 0) {
if ($ttl > 0) {
return self::$cache->setex($this->getNamespace() . $key, $ttl, $value);
return self::$cache->setex($this->getNamespace() . $key, $ttl, json_encode($value));
} else {
return self::$cache->set($this->getNamespace() . $key, $value);
return self::$cache->set($this->getNamespace() . $key, json_encode($value));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment