Skip to content

Commit 0a8b458

Browse files
committed
refactor(Server): Deprecate \OCP\ICache service and replace it with a local cache
Signed-off-by: provokateurin <[email protected]>
1 parent 996c974 commit 0a8b458

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/private/Server.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@ public function __construct($webRoot, \OC\Config $config) {
586586

587587
$this->registerAlias(IURLGenerator::class, URLGenerator::class);
588588

589-
$this->registerAlias(ICache::class, Cache\File::class);
589+
$this->registerService(ICache::class, function ($c) {
590+
/** @var LoggerInterface $logger */
591+
$logger = $c->get(LoggerInterface::class);
592+
$logger->debug('The requested service "' . ICache::class . '" is deprecated. Please use "' . ICacheFactory::class . '" instead to create a cache. This service will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
593+
594+
/** @var ICacheFactory $cacheFactory */
595+
$cacheFactory = $c->get(ICacheFactory::class);
596+
return $cacheFactory->isLocalCacheAvailable() ? $cacheFactory->createLocal() : $cacheFactory->createInMemory();
597+
});
598+
590599
$this->registerService(Factory::class, function (Server $c) {
591600
$profiler = $c->get(IProfiler::class);
592601
$logger = $c->get(LoggerInterface::class);

0 commit comments

Comments
 (0)