diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php index b6f96fffba4eb..d95dd63c81a83 100644 --- a/lib/private/Memcache/Redis.php +++ b/lib/private/Memcache/Redis.php @@ -53,20 +53,21 @@ public function getCache() { } public function get($key) { - $result = $this->getCache()->get($this->getPrefix() . $key); - if ($result === false && !$this->getCache()->exists($this->getPrefix() . $key)) { + $key = $this->getPrefix() . $key; + $result = $this->getCache()->get($key); + if ($result === false) { return null; - } else { - return json_decode($result, true); } + return json_decode($result, true); } public function set($key, $value, $ttl = 0) { + $key = $this->getPrefix() . $key; + $value = json_encode($value); if ($ttl > 0) { - return $this->getCache()->setex($this->getPrefix() . $key, $ttl, json_encode($value)); - } else { - return $this->getCache()->set($this->getPrefix() . $key, json_encode($value)); + return $this->getCache()->set($key, $value, $ttl); } + return $this->getCache()->set($key, $value); } public function hasKey($key) { @@ -74,11 +75,7 @@ public function hasKey($key) { } public function remove($key) { - if ($this->getCache()->unlink($this->getPrefix() . $key)) { - return true; - } else { - return false; - } + return (bool)$this->getCache()->unlink($this->getPrefix() . $key); } public function clear($prefix = '') {