Skip to content

Commit bb3ad22

Browse files
sudkumardrbyte
andauthored
[Docs] Add instructions to reinitialize cache for multi-tenancy key settings (#2804)
* docs(cache): add instructions for cache store change in multi-tenancy when switching cache prefix/key/store during a request lifecycle, after the service provider has been loaded, the cache store should be reinitialized to make sure that the updated CacheStore is used for upcoming cache hits. --------- Co-authored-by: Chris Brown <[email protected]>
1 parent 9d4fa29 commit bb3ad22

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/advanced-usage/cache.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ Laravel Tip: If you are leveraging a caching service such as `redis` or `memcach
6868

6969
To prevent other applications from accidentally using/changing your cached data, it is prudent to set your own cache `prefix` in Laravel's `/config/cache.php` to something unique for each application which shares the same caching service.
7070

71-
Most multi-tenant "packages" take care of this for you when switching tenants.
71+
Most multi-tenant "packages" take care of this for you when switching tenants.
72+
73+
Tip: Most parts of your multitenancy app will relate to a single tenant during a given request lifecycle, so the following step will not be needed: However, in the less-common situation where your app might be switching between multiple tenants during a single request lifecycle (specifically: where changing the cache key/prefix (such as when switching between tenants) or switching the cache store), then after switching tenants or changing the cache configuration you will need to reinitialize the cache of the `PermissionRegistrar` so that the updated `CacheStore` and cache configuration are used.
74+
75+
```php
76+
app()->make(\Spatie\Permission\PermissionRegistrar::class)->initializeCache();
77+
```
7278

7379

7480
### Custom Cache Store

0 commit comments

Comments
 (0)