Skip to content

Commit 4b8a9a1

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

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();
@@ -102,6 +103,9 @@ protected function getQueryBuilder() {
102103
}
103104

104105
public function getStorageCache(): Storage {
106+
if (!$this->storageCache) {
107+
$this->storageCache = new Storage($this->storage, true, $this->cacheDependencies->getConnection());
108+
}
105109
return $this->storageCache;
106110
}
107111

@@ -112,7 +116,7 @@ public function getStorageCache(): Storage {
112116
*/
113117
#[\Override]
114118
public function getNumericStorageId() {
115-
return $this->storageCache->getNumericId();
119+
return $this->getStorageCache()->getNumericId();
116120
}
117121

118122
/**

0 commit comments

Comments
 (0)