Table of Contents

TTenantRoutingCache Class

Caches the tenant and shard information read from an ITenantCatalog, so the catalog is not hit on every request.

Remarks

Entries expire after Ttl milliseconds (0 = never expire, negative = do not cache at all). Unknown tenants are cached for NegativeTtl milliseconds, so repeated requests for nonexistent tenants do not flood the catalog. Entries can also be dropped explicitly with the Invalidate methods, which is what the provisioning classes do after every catalog write so changes are effective immediately. The cache is thread-safe. Catalog reads happen outside its locks, so a slow catalog never blocks lookups that hit the cache. Errors raised by the catalog (other than tenancy exceptions) are wrapped in ETenantCatalogUnavailable; entries that have not expired keep being served while the catalog is unreachable.

Syntax

Unit: Aurelius.Tenancy.Cache

TTenantRoutingCache = class(TObject);

Constructors

Name Description
Create Creates a new TTenantRoutingCache over the given catalog.

Methods

Name Description
FindTenantBy​Identifier Returns the tenant associated with an external identifier, from the cache or from the catalog.
GetShard Returns the information of a shard, from the cache or from the catalog.
GetTenant Returns the routing information of a tenant, from the cache or from the catalog.
InvalidateAll Drops all cached tenant, shard and identifier information.
InvalidateIdentifier Drops the cached mapping of an external identifier, so the next lookup re-reads the catalog.
InvalidateShard Drops the cached information of a shard, so the next lookup re-reads the catalog.
InvalidateTenant Drops the cached information of a tenant, so the next lookup re-reads the catalog.

Properties

Name Description
Catalog The catalog the cache reads from.
NegativeTtl Gets or sets the time, in milliseconds, for which unknown tenant ids are cached.
Ttl Gets or sets the time, in milliseconds, for which tenant and shard information is cached.