aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/memcache/apc.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-04-29 16:34:36 +0200
committerRobin Appelman <icewind@owncloud.com>2015-04-30 14:48:39 +0200
commitacf30ede95f4b8986787f81edcf025a84237b7c5 (patch)
tree8bfd36e370c084793f98a6cf0366916ab27f66cb /lib/private/memcache/apc.php
parent29213b6136a4b2f71e5f981e9bc08e3e76128d4e (diff)
downloadnextcloud-server-acf30ede95f4b8986787f81edcf025a84237b7c5.tar.gz
nextcloud-server-acf30ede95f4b8986787f81edcf025a84237b7c5.zip
add compare and swap to memcache
Diffstat (limited to 'lib/private/memcache/apc.php')
-rw-r--r--lib/private/memcache/apc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/memcache/apc.php b/lib/private/memcache/apc.php
index ba16972e6d6..50b942e7297 100644
--- a/lib/private/memcache/apc.php
+++ b/lib/private/memcache/apc.php
@@ -27,6 +27,10 @@ namespace OC\Memcache;
use OCP\IMemcache;
class APC extends Cache implements IMemcache {
+ use CASTrait {
+ cas as casEmulated;
+ }
+
public function get($key) {
$result = apc_fetch($this->getPrefix() . $key, $success);
if (!$success) {
@@ -89,6 +93,23 @@ class APC extends Cache implements IMemcache {
return apc_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) {
+ // apc only does cas for ints
+ if (is_int($old) and is_int($new)) {
+ return apc_cas($this->getPrefix() . $key, $old, $new);
+ } else {
+ return $this->casEmulated($key, $old, $new);
+ }
+ }
+
static public function isAvailable() {
if (!extension_loaded('apc')) {
return false;