mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Override cache manager only in CacheTagsBootstrapper
This commit is contained in:
parent
1d52096d6e
commit
2171ca9c68
7 changed files with 45 additions and 58 deletions
|
|
@ -10,8 +10,6 @@ use Illuminate\Cache\CacheManager as BaseCacheManager;
|
|||
|
||||
class CacheManager extends BaseCacheManager
|
||||
{
|
||||
public static bool $addTags = false;
|
||||
|
||||
/**
|
||||
* Add tags and forward the call to the inner cache store.
|
||||
*
|
||||
|
|
@ -20,25 +18,21 @@ class CacheManager extends BaseCacheManager
|
|||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (tenancy()->initialized && static::$addTags) {
|
||||
$tags = [config('tenancy.cache.tag_base') . tenant()?->getTenantKey()];
|
||||
$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.");
|
||||
}
|
||||
|
||||
$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));
|
||||
if ($count !== 1) {
|
||||
throw new \Exception("Method tags() takes exactly 1 argument. $count passed.");
|
||||
}
|
||||
|
||||
return $this->store()->tags($tags)->$method(...$parameters);
|
||||
$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));
|
||||
}
|
||||
|
||||
return parent::__call($method, $parameters);
|
||||
return $this->store()->tags($tags)->$method(...$parameters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue