diff --git a/src/CacheManager.php b/src/CacheManager.php index f28134b8..6a662c9a 100644 --- a/src/CacheManager.php +++ b/src/CacheManager.php @@ -18,21 +18,34 @@ class CacheManager extends BaseCacheManager */ public function __call($method, $parameters) { - $tags = [config('tenancy.cache.tag_base') . tenant()->getTenantKey()]; + // todo0 Make PrefixCacheTenancyBootstrapper work with tags + /* if (tenancy()->initialized) { + $tags = [config('tenancy.cache.tag_base') . tenant()?->getTenantKey()]; - if ($method === 'tags') { - $count = count($parameters); + if ($method === 'tags') { + $count = count($parameters); - if ($count !== 1) { - throw new \Exception("Method tags() takes exactly 1 argument. $count passed."); + if ($count !== 1) { + throw new \Exception("Method tags() takes exactly 1 argument. $count passed."); + } + + $names = $parameters[0]; + $names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/9.x/cache#removing-tagged-cache-items + + return $this->store()->tags(array_merge($tags, $names)); } - $names = $parameters[0]; - $names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/9.x/cache#removing-tagged-cache-items + return $this->store()->tags($tags)->$method(...$parameters); + } */ - return $this->store()->tags(array_merge($tags, $names)); - } + return parent::__call($method, $parameters); + } - return $this->store()->tags($tags)->$method(...$parameters); + + public function refreshStore(string|null $repository = null): void + { + $newStore = $this->resolve($repository ?? $this->getDefaultDriver())->getStore(); + + $this->driver($repository)->setStore($newStore); } }