Skip to content

Commit e7c4dbf

Browse files
authored
Merge pull request #58642 from nextcloud/jtr/perf-s3-external-cache-sizing
perf(files_external): Increase S3 cache caps
2 parents 7f18934 + 430975c commit e7c4dbf

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎apps/files_external/lib/Lib/Storage/AmazonS3.php‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public function __construct(array $parameters) {
5353
parent::__construct($parameters);
5454
$this->parseParams($parameters);
5555
$this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']);
56-
$this->objectCache = new CappedMemoryCache();
57-
$this->directoryCache = new CappedMemoryCache();
58-
$this->filesCache = new CappedMemoryCache();
56+
$this->initCaches();
5957
$this->mimeDetector = Server::get(IMimeTypeDetector::class);
6058
/** @var ICacheFactory $cacheFactory */
6159
$cacheFactory = Server::get(ICacheFactory::class);
@@ -84,10 +82,16 @@ private function cleanKey(string $path): string {
8482
return $path;
8583
}
8684

87-
private function clearCache(): void {
88-
$this->objectCache = new CappedMemoryCache();
89-
$this->directoryCache = new CappedMemoryCache();
90-
$this->filesCache = new CappedMemoryCache();
85+
private function initCaches(): void {
86+
$this->objectCache = new CappedMemoryCache(2048);
87+
$this->directoryCache = new CappedMemoryCache(8192);
88+
$this->filesCache = new CappedMemoryCache(4096);
89+
}
90+
91+
private function clearCaches(): void {
92+
$this->objectCache->clear();
93+
$this->directoryCache->clear();
94+
$this->filesCache->clear();
9195
}
9296

9397
private function invalidateCache(string $key): void {
@@ -246,7 +250,7 @@ public function rmdir(string $path): bool {
246250
}
247251

248252
protected function clearBucket(): bool {
249-
$this->clearCache();
253+
$this->clearCaches();
250254
return $this->batchDelete();
251255
}
252256

0 commit comments

Comments
 (0)