1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 14:34:04 +00:00

feat: write cache in separate method

This commit is contained in:
Julian Hundeloh 2024-11-25 20:04:55 +01:00 committed by GitHub
parent 30cdc9461e
commit e7cce6ab43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {