Skip to content

Commit f06a732

Browse files
provokateurincome-nc
authored andcommitted
refactor(Server): Deprecate \OCP\ICache service and replace it with a local cache
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 0374c24 commit f06a732

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/private/Server.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,16 @@ public function __construct(
541541

542542
$this->registerAlias(IURLGenerator::class, URLGenerator::class);
543543

544-
$this->registerAlias(ICache::class, Cache\File::class);
544+
$this->registerService(ICache::class, function ($c) {
545+
/** @var LoggerInterface $logger */
546+
$logger = $c->get(LoggerInterface::class);
547+
$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']);
548+
549+
/** @var ICacheFactory $cacheFactory */
550+
$cacheFactory = $c->get(ICacheFactory::class);
551+
return $cacheFactory->isLocalCacheAvailable() ? $cacheFactory->createLocal() : $cacheFactory->createInMemory();
552+
});
553+
545554
$this->registerService(Factory::class, function (Server $c) {
546555
$profiler = $c->get(IProfiler::class);
547556
$logger = $c->get(LoggerInterface::class);

0 commit comments

Comments
 (0)