Advanced
Cache
In-memory cache of permissions and roles.
Permissions are cached in memory to avoid repeated queries.
config/permissions.ts
defineConfig({
// ...
cache: { enabled: true, key: 'adonisjs_permission_cache', ttl: '24h' },
})
The cache is invalidated automatically when you use the package methods (assignRole, givePermissionTo, ...). If you change data directly in the database or from another process, clear it:
node ace permissions:cache-reset
or in code:
import { PermissionRegistrar } from '@eienjs/adonisjs-permission'
PermissionRegistrar.getInstance().forgetCachedPermissions()
