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

Finish cache invalidation

This commit is contained in:
Samuel Štancl 2020-03-14 19:08:26 +01:00
parent a6102be1a0
commit 2c1cb92745
3 changed files with 49 additions and 8 deletions

View file

@ -64,6 +64,4 @@ class CachedTenantResolver
$this->cache->forget('_tenancy_domain_to_id:' . $domain);
}
}
// todo update cache on writes to data & domains
}

View file

@ -168,10 +168,17 @@ class DatabaseStorageDriver implements StorageDriver, CanDeleteKeys, CanFindByAn
public function deleteTenant(Tenant $tenant): void
{
$originalDomains = $this->domains->getTenantDomains($tenant);
$this->centralDatabase->transaction(function () use ($tenant) {
$this->tenants->where('id', $tenant->id)->delete();
$this->domains->where('tenant_id', $tenant->id)->delete();
});
if ($this->usesCache()) {
$this->cache->invalidateTenant($tenant->id);
$this->cache->invalidateDomainToIdMapping($originalDomains);
}
}
/**