summaryrefslogtreecommitdiffstats
path: root/lib/private/memcache
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2015-01-09 13:12:21 +0000
committerRobin McCorkell <rmccorkell@karoshi.org.uk>2015-01-09 13:18:00 +0000
commit17dd5d0816e500d0818a07bc9ca72b52abce40b3 (patch)
tree247be5ff37288cf2e4fcce489b159d381b44f0fd /lib/private/memcache
parent1f1643b35fef94b64e6997e1af2a3ca87fe0d889 (diff)
downloadnextcloud-server-17dd5d0816e500d0818a07bc9ca72b52abce40b3.tar.gz
nextcloud-server-17dd5d0816e500d0818a07bc9ca72b52abce40b3.zip
Add Null memcacher
Diffstat (limited to 'lib/private/memcache')
-rw-r--r--lib/private/memcache/factory.php4
-rw-r--r--lib/private/memcache/null.php35
2 files changed, 37 insertions, 2 deletions
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index dba9e8a0e00..1e663eecfe1 100644
--- a/lib/private/memcache/factory.php
+++ b/lib/private/memcache/factory.php
@@ -24,7 +24,7 @@ class Factory implements ICacheFactory {
}
/**
- * get a cache instance, will return null if no backend is available
+ * get a cache instance, or Null backend if no backend available
*
* @param string $prefix
* @return \OC\Memcache\Cache
@@ -42,7 +42,7 @@ class Factory implements ICacheFactory {
} elseif (Memcached::isAvailable()) {
return new Memcached($prefix);
} else {
- return null;
+ return new Null($prefix);
}
}
diff --git a/lib/private/memcache/null.php b/lib/private/memcache/null.php
new file mode 100644
index 00000000000..62cd060aaca
--- /dev/null
+++ b/lib/private/memcache/null.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright (c) 2015 Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Memcache;
+
+class Null extends Cache {
+ public function get($key) {
+ return null;
+ }
+
+ public function set($key, $value, $ttl = 0) {
+ return true;
+ }
+
+ public function hasKey($key) {
+ return false;
+ }
+
+ public function remove($key) {
+ return true;
+ }
+
+ public function clear($prefix = '') {
+ return true;
+ }
+
+ static public function isAvailable() {
+ return true;
+ }
+}