Table of Contents

Class InMemoryTeamCache

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

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

teamKey string

Returns

Task<CachedValue<IReadOnlyList<TenantRoleDefinition>>>

GetMemberAsync(string, string)

The membership of userKey in teamKey, or a miss.

public Task<CachedValue<ITeamMember>> GetMemberAsync(string teamKey, string userKey)

Parameters

teamKey string
userKey string

Returns

Task<CachedValue<ITeamMember>>

GetUserAsync(string)

The user resolved for identity, or a miss.

public Task<CachedValue<IUser>> GetUserAsync(string identity)

Parameters

identity string

Returns

Task<CachedValue<IUser>>

RemoveCustomRolesAsync(string)

Forgets one team's custom roles. A no-op when nothing is cached.

public Task RemoveCustomRolesAsync(string teamKey)

Parameters

teamKey string

Returns

Task

RemoveMemberAsync(string, string)

Forgets one membership. A no-op when nothing is cached.

public Task RemoveMemberAsync(string teamKey, string userKey)

Parameters

teamKey string
userKey string

Returns

Task

RemoveMembersForUserAsync(string)

Forgets every membership cached for userKey, across all teams.

public Task RemoveMembersForUserAsync(string userKey)

Parameters

userKey string

Returns

Task

RemoveUserAsync(string)

Forgets the user cached for identity. A no-op when nothing is cached.

public Task RemoveUserAsync(string identity)

Parameters

identity string

Returns

Task

RemoveUserByKeyAsync(string)

public Task RemoveUserByKeyAsync(string userKey)

Parameters

userKey string

Returns

Task

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

teamKey string
customRoles IReadOnlyList<TenantRoleDefinition>

Returns

Task

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

teamKey string
userKey string
member ITeamMember

Returns

Task

SetUserAsync(string, IUser)

Remembers user — which may be null — for identity.

public Task SetUserAsync(string identity, IUser user)

Parameters

identity string
user IUser

Returns

Task