Properly provide local memcache check to ICacheFactory

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-03-13 18:18:04 +01:00
parent 274106b80b
commit dde5353f98
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 12 additions and 4 deletions

View File

@ -185,11 +185,11 @@ class Factory implements ICacheFactory {
} }
/** /**
* check local memcache availability * Check if a local memory cache backend is available
* *
* @return bool * @return bool
*/ */
public function isAvailableLowLatency(): bool { public function isLocalCacheAvailable(): bool {
return ($this->localCacheClass !== self::NULL_CACHE); return ($this->localCacheClass !== self::NULL_CACHE);
} }
} }

View File

@ -567,7 +567,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(\OCP\Route\IRouter::class, function (Server $c) { $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
$cacheFactory = $c->getMemCacheFactory(); $cacheFactory = $c->getMemCacheFactory();
$logger = $c->getLogger(); $logger = $c->getLogger();
if ($cacheFactory->isAvailableLowLatency()) { if ($cacheFactory->isLocalCacheAvailable()) {
$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
} else { } else {
$router = new \OC\Route\Router($logger); $router = new \OC\Route\Router($logger);
@ -581,7 +581,7 @@ class Server extends ServerContainer implements IServerContainer {
}); });
$this->registerAlias('Search', \OCP\ISearch::class); $this->registerAlias('Search', \OCP\ISearch::class);
$this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) {
return new \OC\Security\RateLimiting\Limiter( return new \OC\Security\RateLimiting\Limiter(
$this->getUserSession(), $this->getUserSession(),
$this->getRequest(), $this->getRequest(),

View File

@ -51,6 +51,14 @@ interface ICacheFactory{
*/ */
public function isAvailable(): bool; public function isAvailable(): bool;
/**
* Check if a local memory cache backend is available
*
* @return bool
* @since 14.0.0
*/
public function isLocalCacheAvailable(): bool;
/** /**
* create a cache instance for storing locks * create a cache instance for storing locks
* *