DejaOptions
Global cache defaults, overridable per query via QueryParameters<T> and per
key prefix via DejaClient.SetDefaults.
public sealed class DejaOptionsProperties#
| Property | Type | Default | Description |
|---|---|---|---|
| DefaultStaleTime | TimeSpan | <code>TimeSpan.Zero</code> | How long after a successful fetch data is considered fresh. While fresh, a keyed Execute serves the cache and does not refetch. |
| DefaultCacheTime | TimeSpan | <code>5 minutes</code> | How long an entry with zero subscribers survives before eviction. A component remounting within this window gets its data instantly. |
| DefaultRefetchOnMount | RefetchOnMount | <code>IfStale</code> | Whether a keyed Execute that finds cached data refetches in the background. |
| MaxEntries | int? | <code>null (no cap)</code> | Optional hard cap on cache entries. When exceeded, least-recently-used entries with no subscribers are evicted first. |
| EvictionInterval | TimeSpan | <code>1 minute</code> | How often the eviction sweep runs. |
| StructuralComparison | bool | <code>false</code> | When true, an entry that refetches to a value equal to the current one (per EqualityComparer<T>.Default) keeps its old reference and skips notifying subscribers, so components don't re-render for identical data. |
| TimeProvider | TimeProvider | <code>TimeProvider.System</code> | Clock used for staleness and eviction; swap for a fake in tests. |
Zero stale time is not zero requests
The default stale time of TimeSpan.Zero means cached data renders instantly
but is always revalidated in the background on the next mount — "cached" does not mean
"no request" unless you raise it.
QueryDefaults#
QueryDefaults#
public sealed class QueryDefaults
{
public TimeSpan? StaleTime { get; set; }
public TimeSpan? CacheTime { get; set; }
public RefetchOnMount? RefetchOnMount { get; set; }
}
Per-prefix defaults registered with DejaClient.SetDefaults. Every property
left null falls through to a shorter matching prefix, then to DejaOptions.
Per-query values on QueryParameters<T> beat both.
client.SetDefaults(QueryKey.Of("countries"), new QueryDefaults
{
StaleTime = TimeSpan.FromHours(1),
RefetchOnMount = RefetchOnMount.Never,
});