Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions lib/private/Memcache/Redis.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,32 +53,29 @@ 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);
Comment thread
solracsf marked this conversation as resolved.
}

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) {
return (bool)$this->getCache()->exists($this->getPrefix() . $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 = '') {
Expand Down