diff --git a/src/Bootstrappers/PrefixCacheTenancyBootstrapper.php b/src/Bootstrappers/PrefixCacheTenancyBootstrapper.php index 1e502e1d..dce58029 100644 --- a/src/Bootstrappers/PrefixCacheTenancyBootstrapper.php +++ b/src/Bootstrappers/PrefixCacheTenancyBootstrapper.php @@ -39,30 +39,11 @@ class PrefixCacheTenancyBootstrapper implements TenancyBootstrapper $this->originalPrefix = null; } - protected function syncStore(): void - { - $originalRepository = $this->cacheManager->driver($this->storeName); - - // Delete the repository from CacheManager's $stores cache - // So that it's forced to resolve the repository again on the next attempt to get it - $this->cacheManager->forgetDriver($this->storeName); - - // Let CacheManager create a repository with a fresh store - // To get a new store that uses the current value of `config('cache.prefix')` as the prefix - $newRepository = $this->cacheManager->driver($this->storeName); - - // Give the new store to the old repository - $originalRepository->setStore($newRepository->getStore()); - - // Overwrite the new repository with the modified old one - $this->cacheManager->setStore($this->storeName, $originalRepository); - } - protected function setCachePrefix(string|null $prefix): void { $this->config->set('cache.prefix', $prefix); - $this->syncStore(); + $this->cacheManager->refreshStore(); // It is needed when a call to the facade has been made before bootstrapping tenancy // The facade has its own cache, separate from the container