Tenantry CoreAPI reference
InMemoryTenantStore<TKey> class
Namespace: Tenantry.Core.Stores · Package: Tenantry.Core · API reference
An ITenantStore<TKey> backed by an in-memory dictionary. Suitable for testing, development, demos, and simple single-instance deployments where tenants do not change at runtime.
public sealed class InMemoryTenantStore<TKey> : ITenantStore<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type. Must implementIEquatable<T>andIParsable<TSelf>.
Implements ITenantStore<TKey>.
Constructors
InMemoryTenantStore(IEnumerable<ITenantDescriptor<TKey>>)
Initialises the store with a pre-populated collection of tenants.
public InMemoryTenantStore(IEnumerable<ITenantDescriptor<TKey>> tenants)Parameters:
tenantsIEnumerable<ITenantDescriptor<TKey>>: The tenants the store holds. The store does not change after it is created.
Methods
GetAllTenantsAsync(CancellationToken)
Returns all registered tenants.
public ValueTask<IReadOnlyList<ITenantDescriptor<TKey>>> GetAllTenantsAsync(CancellationToken cancellationToken = default)Parameters:
cancellationTokenCancellationToken: Cancels the lookup.
Returns: ValueTask<IReadOnlyList<ITenantDescriptor<TKey>>>
GetTenantAsync(TKey, CancellationToken)
Returns the tenant with the given tenantId, or null if no matching tenant exists.
public ValueTask<ITenantDescriptor<TKey>?> GetTenantAsync(TKey tenantId, CancellationToken cancellationToken = default)Parameters:
tenantIdTKey: The identifier of the tenant to find.cancellationTokenCancellationToken: Cancels the lookup.
Returns: ValueTask<ITenantDescriptor<TKey>>