Class InMemoryTeamCache
The built-in ITeamCache: entries held in this process, with no expiry, dropped only when a write invalidates them. Registered as a singleton by the toolkit unless a host registered its own.
public sealed class InMemoryTeamCache : ITeamCache
- Inheritance
-
InMemoryTeamCache
- Implements
- Inherited Members
Remarks
Correct for exactly one instance. Every entry is local to this process, so a change made through another instance is not seen here — see ITeamCache for what goes stale and why revalidation does not fix it. Running more than one instance means supplying a shared implementation instead.
No expiry is deliberate rather than an omission: a bounded lifetime would make staleness quieter without
making it shorter in the case that matters, since the entries that go stale are the ones nothing here
writes to. Invalidation is driven by the write paths on UserServiceBase and TeamServiceBase,
which are non-virtual for that reason — a host supplies persistence by overriding the protected member
underneath and cannot skip the invalidation above it.
Methods
GetCustomRolesAsync(string)
The custom roles defined on teamKey, or a miss.
public Task<CachedValue<IReadOnlyList<TenantRoleDefinition>>> GetCustomRolesAsync(string teamKey)
Parameters
teamKeystring
Returns
GetMemberAsync(string, string)
The membership of userKey in teamKey, or a miss.
public Task<CachedValue<ITeamMember>> GetMemberAsync(string teamKey, string userKey)
Parameters
Returns
GetUserAsync(string)
The user resolved for identity, or a miss.
public Task<CachedValue<IUser>> GetUserAsync(string identity)
Parameters
identitystring
Returns
RemoveCustomRolesAsync(string)
Forgets one team's custom roles. A no-op when nothing is cached.
public Task RemoveCustomRolesAsync(string teamKey)
Parameters
teamKeystring
Returns
RemoveMemberAsync(string, string)
Forgets one membership. A no-op when nothing is cached.
public Task RemoveMemberAsync(string teamKey, string userKey)
Parameters
Returns
RemoveMembersForUserAsync(string)
Forgets every membership cached for userKey, across all teams.
public Task RemoveMembersForUserAsync(string userKey)
Parameters
userKeystring
Returns
RemoveUserAsync(string)
Forgets the user cached for identity. A no-op when nothing is cached.
public Task RemoveUserAsync(string identity)
Parameters
identitystring
Returns
RemoveUserByKeyAsync(string)
public Task RemoveUserByKeyAsync(string userKey)
Parameters
userKeystring
Returns
Remarks
A scan, because the entry is keyed by identity. Cheap in practice — one entry per signed-in user per process — and cheaper than maintaining a second index for a call that happens on a write.
SetCustomRolesAsync(string, IReadOnlyList<TenantRoleDefinition>)
Remembers a team's custom roles, including an empty set — the common case, and worth caching.
public 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.
public Task SetMemberAsync(string teamKey, string userKey, ITeamMember member)
Parameters
teamKeystringuserKeystringmemberITeamMember
Returns
SetUserAsync(string, IUser)
Remembers user — which may be null — for identity.
public Task SetUserAsync(string identity, IUser user)