Cache invalidation solution + note (#231)

Because I started to use the cache lookup recently, I've had some issues with the cache invalidation.

I though of sharing the solutions in the documentation:
- Added a solution how to invalidate the cache.

- Added a note/warning to invalidate the cache before  if you intend to update the domain name. Otherwise the invalidate cache will not work as the key will have changed because of the new domain name.
This commit is contained in:
Jori Stein 2022-12-22 04:29:29 -05:00 committed by GitHub
parent 8603a4f04c
commit 3b03605c9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,3 +35,10 @@ DomainTenantResolver::$cacheStore = 'redis';
## Cache invalidation ## Cache invalidation
Updating and saving a Tenant model's attributes will cause the cached entry for this model to be invalidated when `DomainTenantResolver::$shouldCache` is set to `true`. Updating and saving a Tenant model's attributes will cause the cached entry for this model to be invalidated when `DomainTenantResolver::$shouldCache` is set to `true`.
You may invalidate the cache by calling :
```php
app(\Stancl\Tenancy\Resolvers\DomainTenantResolver::class)->invalidateCache($tenant);
```
> Note: When using the domain identification, the key of the cache contains the name of the domain. Make sure to invalidate the cache before making any changes if you intend to update the domain name.