Class ExpressionSqlCache

Assembly: redb.Core.dll

Cache for compiled SQL templates.
Singleton per application with TTL and eviction.
Thread-safe.

public class ExpressionSqlCache

Inheritance

ObjectExpressionSqlCache

Properties

Instance

Gets the singleton instance.

public static ExpressionSqlCache Instance { get; }

Methods

BuildCacheKey<TProps>(Expression<Func<TProps, bool>>, long)

Generates stable cache key from Expression (without constant values).

public string BuildCacheKey<TProps>(Expression<Func<TProps, bool>> predicate, long schemeId)

BuildCacheKey<TProps>(Expression<Func<TProps, bool>>?, IEnumerable<(string field, bool desc)>?, long)

Generates cache key for ordering + filter combination.

public string BuildCacheKey<TProps>(Expression<Func<TProps, bool>>? predicate, IEnumerable<(string field, bool desc)>? ordering, long schemeId)

Clear()

Clears all cached queries. Useful for testing or after schema changes.

public void Clear()

GetStats()

Cache statistics (for monitoring).

public (long Count, long Size) GetStats()

Set(string, CompiledQuery)

Sets cached query.

public void Set(string key, CompiledQuery query)

TryGet(string, out CompiledQuery?)

Tries to get cached query.

public bool TryGet(string key, out CompiledQuery? query)