summaryrefslogtreecommitdiffstats
path: root/lib/memcache/factory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/memcache/factory.php')
-rw-r--r--lib/memcache/factory.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/memcache/factory.php b/lib/memcache/factory.php
index 4c1b1ab207f..fde7d947567 100644
--- a/lib/memcache/factory.php
+++ b/lib/memcache/factory.php
@@ -37,4 +37,33 @@ class Factory {
public function isAvailable() {
return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable() || Memcached::isAvailable();
}
+
+ /**
+ * get a in-server cache instance, will return null if no backend is available
+ *
+ * @param string $prefix
+ * @return \OC\Memcache\Cache
+ */
+ public static function createLowLatency($prefix = '') {
+ if (XCache::isAvailable()) {
+ return new XCache($prefix);
+ } elseif (APCu::isAvailable()) {
+ return new APCu($prefix);
+ } elseif (APC::isAvailable()) {
+ return new APC($prefix);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * check if there is a in-server backend available
+ *
+ * @return bool
+ */
+ public static function isAvailableLowLatency() {
+ return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
+ }
+
+
}