Skip to content

Commit 1cfc226

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

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
@@ -585,7 +585,16 @@ public function __construct($webRoot, \OC\Config $config) {
585585

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

588-
$this->registerAlias(ICache::class, Cache\File::class);
588+
$this->registerService(ICache::class, function ($c) {
589+
/** @var LoggerInterface $logger */
590+
$logger = $c->get(LoggerInterface::class);
591+
$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']);
592+
593+
/** @var ICacheFactory $cacheFactory */
594+
$cacheFactory = $c->get(ICacheFactory::class);
595+
return $cacheFactory->isLocalCacheAvailable() ? $cacheFactory->createLocal() : $cacheFactory->createInMemory();
596+
});
597+
589598
$this->registerService(Factory::class, function (Server $c) {
590599
$profiler = $c->get(IProfiler::class);
591600
$logger = $c->get(LoggerInterface::class);

0 commit comments

Comments
 (0)