Interface ITeamCache
Where the toolkit keeps the three lookups its claims path performs on every authenticating request: the caller, their membership in the selected team, and that team's custom roles.
public interface ITeamCache
Remarks
Implement this to run more than one instance. The built-in InMemoryTeamCache is process-local, so a permission change made through one instance never reaches the others — a suspended member keeps their scopes, and a disabled user keeps their session, on every instance that did not handle the write, until that instance restarts. Periodic claim revalidation does not correct it: it recomputes through this same cache. A shared implementation (Redis, SQL, or any store every instance can see) is what makes a multi-instance deployment enforce a change everywhere.
Only you can serialize these values. IUser and ITeamMember are interfaces your own entities implement, so a distributed adapter serializes types it defines. That is why this port exists rather than the toolkit shipping a distributed cache: the toolkit does not know the concrete types.
Every member may be a no-op. Returning Miss from every read is a correct implementation — it disables caching and sends each lookup to the store. Nothing here may throw on a miss, and a cache that fails should prefer reporting a miss over propagating: a read that cannot be cached is slow, whereas one that throws breaks sign-in.
Removal is expressed as what the caller changed, not as a key to delete, so an adapter is free to key its store however it likes. The two by-user removals are the awkward pair for a distributed store, because neither is keyed the way the entry is: expect to keep a companion index from a user key to that user's identity and teams.
Methods
GetCustomRolesAsync(string)
The custom roles defined on teamKey, or a miss.
Task<CachedValue<IReadOnlyList<TenantRoleDefinition>>> GetCustomRolesAsync(string teamKey)
Parameters
teamKeystring
Returns
GetMemberAsync(string, string)
The membership of userKey in teamKey, or a miss.
Task<CachedValue<ITeamMember>> GetMemberAsync(string teamKey, string userKey)
Parameters
Returns
GetUserAsync(string)
The user resolved for identity, or a miss.
Task<CachedValue<IUser>> GetUserAsync(string identity)
Parameters
identitystring
Returns
RemoveCustomRolesAsync(string)
Forgets one team's custom roles. A no-op when nothing is cached.
Task RemoveCustomRolesAsync(string teamKey)
Parameters
teamKeystring
Returns
RemoveMemberAsync(string, string)
Forgets one membership. A no-op when nothing is cached.
Task RemoveMemberAsync(string teamKey, string userKey)
Parameters
Returns
RemoveMembersForUserAsync(string)
Forgets every membership cached for userKey, across all teams.
Task RemoveMembersForUserAsync(string userKey)
Parameters
userKeystring
Returns
RemoveUserAsync(string)
Forgets the user cached for identity. A no-op when nothing is cached.
Task RemoveUserAsync(string identity)
Parameters
identitystring
Returns
RemoveUserByKeyAsync(string)
Forgets whichever cached user has this Key. Needed because the entry is keyed by identity while the toolkit's write paths name a user by key.
Task RemoveUserByKeyAsync(string userKey)
Parameters
userKeystring
Returns
SetCustomRolesAsync(string, IReadOnlyList<TenantRoleDefinition>)
Remembers a team's custom roles, including an empty set — the common case, and worth caching.
Task SetCustomRolesAsync(string teamKey, IReadOnlyList<TenantRoleDefinition> customRoles)
Parameters
teamKeystringcustomRolesIReadOnlyList<TenantRoleDefinition>
Returns
SetMemberAsync(string, string, ITeamMember)
Remembers member — which may be null, meaning "not a member" — for this pair.
Task SetMemberAsync(string teamKey, string userKey, ITeamMember member)
Parameters
teamKeystringuserKeystringmemberITeamMember
Returns
SetUserAsync(string, IUser)
Remembers user — which may be null — for identity.
Task SetUserAsync(string identity, IUser user)