summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-11-10 15:58:17 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-10 15:58:17 +0100
commitc9b671a12fd0a875d16712408aa35abaf00a2d37 (patch)
treee8de79f0afee96398c5fdc1e5720f7a108c788b6 /lib
parentbbe2f5c2d57d57d5f89a76b63b9ba43bd0168169 (diff)
downloadnextcloud-server-c9b671a12fd0a875d16712408aa35abaf00a2d37.tar.gz
nextcloud-server-c9b671a12fd0a875d16712408aa35abaf00a2d37.zip
Handle errors on memcached level - fixes #17397
Diffstat (limited to 'lib')
-rw-r--r--lib/private/memcache/memcached.php38
1 files changed, 30 insertions, 8 deletions
diff --git a/lib/private/memcache/memcached.php b/lib/private/memcache/memcached.php
index ce7c6fa9577..22b54f7bc95 100644
--- a/lib/private/memcache/memcached.php
+++ b/lib/private/memcache/memcached.php
@@ -41,9 +41,9 @@ class Memcached extends Cache implements IMemcache {
parent::__construct($prefix);
if (is_null(self::$cache)) {
self::$cache = new \Memcached();
- $servers = \OC_Config::getValue('memcached_servers');
+ $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
if (!$servers) {
- $server = \OC_Config::getValue('memcached_server');
+ $server = \OC::$server->getSystemConfig()->getValue('memcached_server');
if ($server) {
$servers = array($server);
} else {
@@ -72,10 +72,12 @@ class Memcached extends Cache implements IMemcache {
public function set($key, $value, $ttl = 0) {
if ($ttl > 0) {
- return self::$cache->set($this->getNamespace() . $key, $value, $ttl);
+ $result = self::$cache->set($this->getNamespace() . $key, $value, $ttl);
} else {
- return self::$cache->set($this->getNamespace() . $key, $value);
+ $result = self::$cache->set($this->getNamespace() . $key, $value);
}
+ $this->verifyReturnCode();
+ return $result;
}
public function hasKey($key) {
@@ -84,7 +86,9 @@ class Memcached extends Cache implements IMemcache {
}
public function remove($key) {
- return self::$cache->delete($this->getNamespace() . $key);
+ $result= self::$cache->delete($this->getNamespace() . $key);
+ $this->verifyReturnCode();
+ return $result;
}
public function clear($prefix = '') {
@@ -121,7 +125,9 @@ class Memcached extends Cache implements IMemcache {
* @return bool
*/
public function add($key, $value, $ttl = 0) {
- return self::$cache->add($this->getPrefix() . $key, $value, $ttl);
+ $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
+ $this->verifyReturnCode();
+ return $result;
}
/**
@@ -133,7 +139,9 @@ class Memcached extends Cache implements IMemcache {
*/
public function inc($key, $step = 1) {
$this->add($key, 0);
- return self::$cache->increment($this->getPrefix() . $key, $step);
+ $result = self::$cache->increment($this->getPrefix() . $key, $step);
+ $this->verifyReturnCode();
+ return $result;
}
/**
@@ -144,10 +152,24 @@ class Memcached extends Cache implements IMemcache {
* @return int | bool
*/
public function dec($key, $step = 1) {
- return self::$cache->decrement($this->getPrefix() . $key, $step);
+ $result = self::$cache->decrement($this->getPrefix() . $key, $step);
+ $this->verifyReturnCode();
+ return $result;
}
static public function isAvailable() {
return extension_loaded('memcached');
}
+
+ /**
+ * @throws \Exception
+ */
+ private function verifyReturnCode() {
+ $code = self::$cache->getResultCode();
+ if ($code === \Memcached::RES_SUCCESS) {
+ return;
+ }
+ $message = self::$cache->getResultMessage();
+ throw new \Exception("Error $code interacting with memcached : $message");
+ }
}