CacheOptions
CacheOptions is the single configuration object for the reflection cache. Every tunable lives here — size caps, eviction algorithm, tracking toggles, and the auto-validation safety net.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
MaxCacheSize | int | 1000 | Maximum number of entries each store will hold before an eviction pass runs. |
LeastUsedThreshold | int | 25 | Percentage of entries to remove on a single eviction pass — the "least valuable" slice. |
MostUsedThreshold | int | 75 | Bookkeeping only — must equal 100 − LeastUsedThreshold, and Validate() corrects it when it does not. Eviction reads LeastUsedThreshold alone. |
EvictionStrategy | CacheEvictionStrategy | LRU | Algorithm used to pick the least-valuable entries: FIFO, LRU, or LFU. |
EnableLruTracking | bool | true | Reported only. Timestamp tracking follows EvictionStrategy; auto-validation overwrites whatever you set here. |
EnableLfuTracking | bool | false | Reported only. Frequency tracking follows EvictionStrategy; auto-validation overwrites whatever you set here. |
AutoValidateConfiguration | bool | true | Auto-corrects mismatched settings — e.g. enables EnableLfuTracking when EvictionStrategy = LFU. |
Note
Set
LeastUsedThreshold on its own. There is no setter logic: the two values are reconciled inside Validate(), which Configure calls, and only in one direction — MostUsedThreshold becomes 100 − LeastUsedThreshold when AutoValidateConfiguration is on (the default), and throws when it is off. The 50–99 range check on MostUsedThreshold runs first, so an out-of-range value still throws even though the correction would have overwritten it.Defaults in code
There is no CacheOptions.Default. The default options object is new CacheOptions(), equivalent to:
var defaults = new CacheOptions
{
MaxCacheSize = 1000,
LeastUsedThreshold = 25,
MostUsedThreshold = 75,
EvictionStrategy = CacheEvictionStrategy.LRU,
EnableLruTracking = true,
EnableLfuTracking = false,
AutoValidateConfiguration = true,
};Strategy ↔ tracking matrix
When AutoValidateConfiguration is on, Validate() overwrites the two tracking flags to match EvictionStrategy. With it off, a flag that does not match the strategy throws instead — including the EnableLruTracking default of true under FIFO or LFU.
| EvictionStrategy | EnableLruTracking | EnableLfuTracking |
|---|---|---|
FIFO | false | false |
LRU | true | false |
LFU | false | true |