summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-07-24 21:50:15 +0200
committerBart Visscher <bartv@thisnet.nl>2013-07-24 21:50:15 +0200
commit25003fb21380b71f7c098b8e27263031103e1655 (patch)
tree3b742fe31dc3ffb3bd43393f6c479567b2304fad /lib
parent9a97875977ed2f319ef18f13786687c09084cb02 (diff)
downloadnextcloud-server-25003fb21380b71f7c098b8e27263031103e1655.tar.gz
nextcloud-server-25003fb21380b71f7c098b8e27263031103e1655.zip
Add ACPu memory cache
Diffstat (limited to 'lib')
-rw-r--r--lib/memcache/apcu.php28
-rw-r--r--lib/memcache/factory.php4
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/memcache/apcu.php b/lib/memcache/apcu.php
new file mode 100644
index 00000000000..ccc1aa6e562
--- /dev/null
+++ b/lib/memcache/apcu.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Memcache;
+
+class APCu extends APC {
+ public function clear($prefix = '') {
+ $ns = $this->getNamespace() . $prefix;
+ $ns = preg_quote($ns, '/');
+ $iter = new \APCIterator('/^'.$ns.'/');
+ return apc_delete($iter);
+ }
+
+ static public function isAvailable() {
+ if (!extension_loaded('apcu')) {
+ return false;
+ } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
diff --git a/lib/memcache/factory.php b/lib/memcache/factory.php
index b1b49971031..4c1b1ab207f 100644
--- a/lib/memcache/factory.php
+++ b/lib/memcache/factory.php
@@ -18,6 +18,8 @@ class Factory {
function create($prefix = '') {
if (XCache::isAvailable()) {
return new XCache($prefix);
+ } elseif (APCu::isAvailable()) {
+ return new APCu($prefix);
} elseif (APC::isAvailable()) {
return new APC($prefix);
} elseif (Memcached::isAvailable()) {
@@ -33,6 +35,6 @@ class Factory {
* @return bool
*/
public function isAvailable() {
- return XCache::isAvailable() || APC::isAvailable() || Memcached::isAvailable();
+ return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable();
}
}