- Substantial speed increase by caching the associations between models and permissions
NOTES:
The following changes are not "breaking", but worth making the updates to your app for consistency.
-
Config file: The
config/permission.php
file changed to move cache-related settings into a sub-array. You should review the changes and merge the updates into your own config file. Specifically theexpiration_time
value has moved into a sub-array entry, and the old top-level entry is no longer used.
See the master config file here:
https://github.com/spatie/laravel-permission/blob/master/config/permission.php -
Cache Resets: If your
app
ortests
are clearing the cache by specifying the cache key, it is better to use the built-in forgetCachedPermissions() method so that it properly handles tagged cache entries. Here is the recommended change:
- app()['cache']->forget('spatie.permission.cache');
+ $this->app->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
- Also this is a good time to point out that now with v2.25.0 and v2.26.0 most permission-cache-reset scenarios may no longer be needed in your app, so it's worth reviewing those cases, as you may gain some app speed improvement by removing unnecessary cache resets.