Table of Contents

Class CacheConfiguration

Namespace
CL.MySQL2.Configuration
Assembly
CL.MySQL2.dll

Process-wide cache configuration for CL.MySQL2. Applies to all databases unless a per-database override is set on CacheEnabledOverride.

[ConfigSection("mysql.cache")]
public sealed class CacheConfiguration : ConfigModelBase
Inheritance
ConfigModelBase
CacheConfiguration
Inherited Members
ConfigModelBase.Validate()

Properties

DefaultTtlSeconds

Default cache lifetime used by the parameterless WithCache() overload on QueryBuilder<T> and ProjectedQuery<TSource, TResult>. A WithCache(TimeSpan) call still wins for that query.

[ConfigField(Label = "Default TTL (seconds)", Min = 1, Description = "Default cache lifetime when .WithCache() has no TTL argument.", Group = "Behavior", Order = 20)]
public int DefaultTtlSeconds { get; set; }

Property Value

int

Enabled

Master switch for the query result cache.

[ConfigField(Label = "Enabled", Description = "Turn the query result cache on or off globally.", Group = "General", Order = 0)]
public bool Enabled { get; set; }

Property Value

bool

MaxEntries

Maximum number of cached entries across all databases.

[ConfigField(Label = "Max Entries", Min = 0, Description = "Total cached entries. Soft cap enforced lazily.", Group = "Capacity", Order = 10)]
public int MaxEntries { get; set; }

Property Value

int

MaxMemoryMb

Obsolete. The in-process store bounds the cache by entry count, not by bytes — use MaxEntries. Retained so existing config files keep deserializing.

[Obsolete("The in-process cache store bounds by entry count, not bytes. Use MaxEntries instead; this value is ignored.")]
[ConfigField(Label = "Max Memory (MB)", Min = 0, Description = "Obsolete and ignored — the in-process store evicts by entry count. Use Max Entries.", Group = "Capacity", Order = 11, Collapsed = true)]
public int MaxMemoryMb { get; set; }

Property Value

int

PublishEvents

Whether CacheHitEvent / CacheMissEvent are published. When false the cache still works; it just stops emitting hit/miss observability events. Default: true.

[ConfigField(Label = "Publish Cache Events", Description = "Emit CacheHitEvent / CacheMissEvent for observability.", Group = "Observability", Order = 30)]
public bool PublishEvents { get; set; }

Property Value

bool

TimeQuantizeSeconds

Time-near-now closure values used as query parameters (e.g. DateTime.UtcNow.AddDays(-30)) are rounded down to this window when forming the cache key. Without this, every call produces a unique cache key and nothing ever hits. Set to 0 to disable and use raw timestamps.

[ConfigField(Label = "Time Quantize (seconds)", Min = 0, Description = "Round DateTime parameters to this window when building cache keys. 0 disables.", Group = "Behavior", Order = 21)]
public int TimeQuantizeSeconds { get; set; }

Property Value

int