Class MemoryRedbObjectCache

Assembly: redb.Core.dll

In-memory cache implementation for WHOLE RedbObject (not just Props!).
Cache key = objectId, Hash is used for automatic invalidation.
We cache entire object for 0 DB queries on Cache HIT and nested object reuse through references.

public class MemoryRedbObjectCache : IRedbObjectCache

Inheritance

ObjectMemoryRedbObjectCache

Implements

Methods

Clear()

Clear entire cache

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.

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 from cache with hash validation.

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

GetStats()

Get cache statistics

public PropsCacheStatistics GetStats()

GetUserStatistics()

Get detailed user statistics.

public Dictionary<long, UserCacheStats> GetUserStatistics()

GetWithoutHashValidation<TProps>(long)

Get WHOLE RedbObject from cache WITHOUT hash validation.

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

Remove(long)

Remove object 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