diff --git a/classes/BaseDocumentation.php b/classes/BaseDocumentation.php index ac06e2e..e8d7c66 100644 --- a/classes/BaseDocumentation.php +++ b/classes/BaseDocumentation.php @@ -1,15 +1,16 @@ repositoryEditUrl = $config['repository']['editUrl'] ?? null; } + /** + * Gets the cache key for this documentation. + */ + public function getCacheKey(string $suffix = ''): string + { + return !empty($suffix) ? $this->getIdentifier() . '.' . $suffix : $this->getIdentifier(); + } + /** * Gets the identifier of the documentation. */ @@ -159,10 +168,12 @@ public function isAvailable(): bool return $this->available; } - return $this->available = ( - $this->getStorageDisk()->exists($this->getProcessedPath('page-map.json')) - && $this->getStorageDisk()->exists($this->getProcessedPath('toc.json')) - ); + return $this->available = Cache::rememberForever($this->getCacheKey('available'), function () { + return ( + $this->getStorageDisk()->exists($this->getProcessedPath('page-map.json')) + && $this->getStorageDisk()->exists($this->getProcessedPath('toc.json')) + ); + }); } /** @@ -532,9 +543,11 @@ public function getProcessedAssetsPath(string $suffix = ''): string */ public function getProcessedFile(string $path): ?string { - return $this->getStorageDisk()->get( - $this->getProcessedPath($path) - ) ?? null; + return Cache::rememberForever('winter.docs::storage.processedFileContents.' . $this->getCacheKey($path), function () use ($path) { + return $this->getStorageDisk()->get( + $this->getProcessedPath($path) + ) ?? null; + }); } /**