class PermissionCache

Caches the permission lists of group-ID sets for the lifetime of the application instance.

The permissions a user has are fully determined by the set of group IDs they belong to, so users sharing a group set can share one `group_permission` load. Without this, any code that checks an ability against each serialized user — extension serializer flags, policies, visibility scopers — issues one identical query per user instance. The cache is a container singleton, so its lifetime is one request under PHP-FPM. Entries are invalidated when permissions change: per affected group for model writes, and wholesale for the admin permission endpoint (which writes through the query builder and bypasses model events). Code that modifies the `group_permission` table directly should call `flush()`.

Properties

protected array<string,string[]> $permissions Permission lists keyed by sorted group-ID set.

Methods

array|null
get(array $groupIds)

No description

void
put(array $groupIds, array $permissions)

No description

void
forgetGroup(int $groupId)

Forget every cached set that contains the given group, e.g. because the group's permissions changed or the group was deleted.

void
flush()

No description

string
key(array $groupIds)

No description

Details

array|null get(array $groupIds)

Parameters

array $groupIds

Return Value

array|null

void put(array $groupIds, array $permissions)

Parameters

array $groupIds
array $permissions

Return Value

void

void forgetGroup(int $groupId)

Forget every cached set that contains the given group, e.g. because the group's permissions changed or the group was deleted.

Parameters

int $groupId

Return Value

void

void flush()

Return Value

void

protected string key(array $groupIds)

Parameters

array $groupIds

Return Value

string