Class GlobalPropsCache

Assembly: redb.Core.dll

Domain-isolated cache for WHOLE RedbObject (not just Props!).
Transparent to business code: if disabled (Cache == null), everything goes through DB.
Instance is bound to specific domain, static data is shared.

public sealed class GlobalPropsCache

Inheritance

ObjectGlobalPropsCache

Properties

Domain

Domain identifier for this cache instance.

public string Domain { get; }

Instance

Get underlying cache instance for this domain.

public IRedbObjectCache? Instance { get; }

Methods

Clear()

Clear cache for this domain.

public void Clear()

FilterNeedToLoad<TProps>(List<(long objectId, Guid hash)>, out Dictionary<long, RedbObject<TProps>>)

BULK: determine which objects need to be loaded from DB (set difference).

public HashSet<long> FilterNeedToLoad<TProps>(List<(long objectId, Guid hash)> objects, out Dictionary<long, RedbObject<TProps>> fromCache) where TProps : class, new()

Get<TProps>(long, Guid)

Get WHOLE RedbObject with hash validation.

public RedbObject<TProps>? Get<TProps>(long objectId, Guid hash) where TProps : class, new()

GetStats()

Get cache statistics for this domain.

public PropsCacheStatistics GetStats()

GetWithoutHashValidation<TProps>(long)

Get WHOLE RedbObject WITHOUT hash validation (for monolithic applications).

public RedbObject<TProps>? GetWithoutHashValidation<TProps>(long objectId) where TProps : class, new()

Initialize(IRedbObjectCache)

Initialize cache for this domain (called once at application startup per domain).

public void Initialize(IRedbObjectCache cache)

Remove(long)

Remove from cache.

public void Remove(long objectId)

Set<TProps>(RedbObject<TProps>)

Save WHOLE RedbObject to cache.

public void Set<TProps>(RedbObject<TProps> obj) where TProps : class, new()

Constructors

GlobalPropsCache(string?)

Create cache instance for specific domain.