mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Add Null memcacher
This commit is contained in:
parent
1f1643b35f
commit
17dd5d0816
2 changed files with 37 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
35
lib/private/memcache/null.php
Normal file
35
lib/private/memcache/null.php
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue