mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:34:03 +00:00
Fix #31 CacheManager didn't merge tags properly; write tests for CacheManager
This commit is contained in:
parent
e463829e53
commit
a2d68b1261
3 changed files with 31 additions and 10 deletions
|
|
@ -9,13 +9,16 @@ class CacheManager extends BaseCacheManager
|
|||
public function __call($method, $parameters)
|
||||
{
|
||||
$tags = [config('tenancy.cache.tag_base') . tenant('uuid')];
|
||||
|
||||
|
||||
if ($method === "tags") {
|
||||
if (count($parameters) == 1 && is_array($parameters[0])) {
|
||||
$parameters = [$parameters]; // cache()->tags('foo') https://laravel.com/docs/5.7/cache#removing-tagged-cache-items
|
||||
if (count($parameters) !== 1) {
|
||||
throw new \Exception("Method tags() takes exactly 1 argument. {count($parameters)} passed.");
|
||||
}
|
||||
|
||||
return $this->store()->tags(array_merge($tags, ...$parameters));
|
||||
$names = $parameters[0];
|
||||
$names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/5.7/cache#removing-tagged-cache-items
|
||||
|
||||
return $this->store()->tags(array_merge($tags, $names));
|
||||
}
|
||||
|
||||
return $this->store()->tags($tags)->$method(...$parameters);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue