mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 22:44:05 +00:00
feat: write cache in separate method
This commit is contained in:
parent
30cdc9461e
commit
e7cce6ab43
1 changed files with 10 additions and 5 deletions
|
|
@ -34,20 +34,25 @@ abstract class CachedTenantResolver implements TenantResolver
|
|||
return $this->resolveWithoutCache(...$args);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey(...$args);
|
||||
|
||||
if ($tenant = $this->cache->get($key)) {
|
||||
if ($tenant = $this->cache->get($this->getCacheKey(...$args))) {
|
||||
$this->resolved($tenant, ...$args);
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
||||
$tenant = $this->resolveWithoutCache(...$args);
|
||||
$this->cache->put($key, $tenant, static::$cacheTTL);
|
||||
$this->writeCache(...$args);
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
||||
public function writeCache(...$args): void
|
||||
{
|
||||
$key = $this->getCacheKey(...$args);
|
||||
$tenant = $this->resolveWithoutCache(...$args);
|
||||
|
||||
$this->cache->put($key, $tenant, static::$cacheTTL);
|
||||
}
|
||||
|
||||
public function invalidateCache(Tenant $tenant): void
|
||||
{
|
||||
if (! static::$shouldCache) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue