Docs
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 implement IEquatable<T> and IParsable<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:

  • tenants IEnumerable<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:

  • cancellationToken CancellationToken: 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:

  • tenantId TKey: The identifier of the tenant to find.
  • cancellationToken CancellationToken: Cancels the lookup.

Returns: ValueTask<ITenantDescriptor<TKey>>

On this page