Skip to content

Commit

Permalink
Merge pull request #47 from Noaber/fix-folder-cache-key-tenants
Browse files Browse the repository at this point in the history
fix folder cache issue for multitenancy installations
  • Loading branch information
RicLeP authored Jan 19, 2024
2 parents 0bda682 + 38ad9ff commit aebbee8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ protected function get()
if (request()->has('_storyblok') || !config('storyblok.cache')) {
$response = $this->makeRequest();
} else {
$uniqueTag = md5(serialize($this->getSettings()));
$apiHash = md5(config('storyblok.api_public_key') ?? config('storyblok.api_preview_key')); // unique id for multitenancy applications
$uniqueTag = md5(serialize($this->getSettings()));

$response = Cache::remember($this->cacheKey . $this->slug . '-' . $uniqueTag, config('storyblok.cache_duration') * 60, function () {
$response = Cache::remember($this->cacheKey . $this->slug . '-' . $apiHash . '-' . $uniqueTag, config('storyblok.cache_duration') * 60, function () {
return $this->makeRequest();
});
}
Expand Down Expand Up @@ -269,4 +270,4 @@ public function toArray(): array
{
return $this->stories->toArray();
}
}
}

0 comments on commit aebbee8

Please sign in to comment.