Skip to content

Commit 123d018

Browse files
committed
perf: delay loading storage info in Cache untill needed
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 6afd7bf commit 123d018

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/private/Files/Cache/Cache.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,15 @@ class Cache implements ICache {
6262
*/
6363
protected array $partial = [];
6464
protected string $storageId;
65-
protected Storage $storageCache;
65+
protected ?Storage $storageCache = null;
6666
protected IMimeTypeLoader $mimetypeLoader;
6767
protected IDBConnection $connection;
6868
protected SystemConfig $systemConfig;
6969
protected LoggerInterface $logger;
7070
protected QuerySearchHelper $querySearchHelper;
7171
protected IEventDispatcher $eventDispatcher;
7272
protected IFilesMetadataManager $metadataManager;
73+
private CacheDependencies $cacheDependencies;
7374

7475
public function __construct(
7576
private IStorage $storage,
@@ -84,7 +85,7 @@ public function __construct(
8485
if (!$dependencies) {
8586
$dependencies = Server::get(CacheDependencies::class);
8687
}
87-
$this->storageCache = new Storage($this->storage, true, $dependencies->getConnection());
88+
$this->cacheDependencies = $dependencies;
8889
$this->mimetypeLoader = $dependencies->getMimeTypeLoader();
8990
$this->connection = $dependencies->getConnection();
9091
$this->systemConfig = $dependencies->getSystemConfig();
@@ -111,7 +112,10 @@ public function getStorageCache(): Storage {
111112
* @return int
112113
*/
113114
public function getNumericStorageId() {
114-
return $this->storageCache->getNumericId();
115+
if (!$this->storageCache) {
116+
$this->storageCache = new Storage($this->storage, true, $this->cacheDependencies->getConnection());
117+
}
118+
return $this->getStorageCache()->getNumericId();
115119
}
116120

117121
/**

0 commit comments

Comments
 (0)