Class MemoryRedbObjectCache
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
Implements
Methods
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()
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()
Set<TProps>(RedbObject<TProps>)
Save WHOLE RedbObject to cache
public void Set<TProps>(RedbObject<TProps> obj) where TProps : class, new()