From a40a237441670a4c575a224158b4a2a7c2fb5266 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 30 Apr 2015 13:39:31 +0200 Subject: [PATCH] use trait for cas polyfill for xcache --- lib/private/memcache/xcache.php | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/lib/private/memcache/xcache.php b/lib/private/memcache/xcache.php index 3a5bd73d8ad..0be79d06ed9 100644 --- a/lib/private/memcache/xcache.php +++ b/lib/private/memcache/xcache.php @@ -32,6 +32,8 @@ use OCP\IMemcache; * functions etc. */ class XCache extends Cache implements IMemcache { + use CASTrait; + /** * entries in XCache gets namespaced to prevent collisions between ownCloud instances and users */ @@ -107,30 +109,6 @@ class XCache extends Cache implements IMemcache { return xcache_dec($this->getPrefix() . $key, $step); } - /** - * Compare and set - * - * @param string $key - * @param mixed $old - * @param mixed $new - * @return bool - */ - public function cas($key, $old, $new) { - //no native cas, emulate with locking - if ($this->add($key . '_lock', true)) { - if ($this->get($key) === $old) { - $this->set($key, $new); - $this->remove($key . '_lock'); - return true; - } else { - $this->remove($key . '_lock'); - return false; - } - } else { - return false; - } - } - static public function isAvailable() { if (!extension_loaded('xcache')) { return false;