Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from SETEX to SET EX #37350

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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 number Diff line number Diff 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 && !$this->getCache()->exists($key)) {
return null;
} else {
return json_decode($result, true);
}
return json_decode($result, true);
solracsf marked this conversation as resolved.
Show resolved Hide 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()->del($this->getPrefix() . $key)) {
return true;
} else {
return false;
}
return (bool)$this->getCache()->del($this->getPrefix() . $key);
}

public function clear($prefix = '') {
Expand Down