Table of Contents

Interface IQueryCacheEntry

Namespace
DotNetQuery.Core.Inspection
Assembly
DotNetQuery.Core.dll

A read-only view of one entry in a query client's cache — a regular or an infinite query — plus the actions that are safe to invoke on an entry the cache owns. Obtained from Entries.

public interface IQueryCacheEntry

Remarks

This is a live view, not a snapshot: every property reads the entry's state at the moment it is accessed. Read the properties when handling an Entries emission and copy what you need, rather than holding on to the entry and reading it later from another thread.

The cache owns the entry's lifetime. There is deliberately no way to dispose it from here — an entry is evicted once it has had no subscribers for its CacheTime.

Properties

CacheTime

How long the entry stays in the cache after its last subscriber disposes.

TimeSpan CacheTime { get; }

Property Value

TimeSpan

CurrentData

The data held by the entry, untyped. For a regular query this is the data of the latest successful fetch, and null while a fetch is in progress or after a failure — see LastData for the value carried across those states. For an infinite query it is an array of the loaded pages (TData[]), retained across fetches and failures, or null when no page has loaded.

object? CurrentData { get; }

Property Value

object

Remarks

The value is a consumer type. Rendering or serializing it is the inspector's job; note that reflection-based serialization is not trim- or AOT-safe.

Error

The exception from the most recent failed fetch; null unless Status is Failure.

Exception? Error { get; }

Property Value

Exception

IsStale

true when the entry would be re-fetched by an invalidation or by its next subscriber: it has never succeeded, its data is older than its StaleTime, or it was invalidated while it had no subscribers.

bool IsStale { get; }

Property Value

bool

Remarks

Evaluated when read. An entry becoming stale purely through elapsed time does not cause an Entries emission.

Key

The key that identifies this entry in the cache.

QueryKey Key { get; }

Property Value

QueryKey

LastData

For a regular query, the data from the previous successful fetch, carried forward across subsequent fetches and failures — the value to show while CurrentData is null during a refetch. Always null for an infinite query, whose CurrentData already retains its pages across fetches.

object? LastData { get; }

Property Value

object

LastUpdatedAt

When data was last written to the entry — by a successful fetch or a SetData call — on the client's scheduler clock. null until the first success.

DateTimeOffset? LastUpdatedAt { get; }

Property Value

DateTimeOffset?

Name

A low-cardinality, human-readable name for the entry: the query's Name option when set, otherwise the first part of Key, otherwise "unknown". This is the same value that tags the entry's metrics.

string Name { get; }

Property Value

string

ObserverCount

The number of active subscribers to the entry's state.

int ObserverCount { get; }

Property Value

int

Status

The current lifecycle status of the entry.

QueryStatus Status { get; }

Property Value

QueryStatus

Methods

Cancel()

Cancels the entry's in-flight fetch, if any.

void Cancel()

Invalidate()

Marks the entry as stale. Re-fetches immediately when it has subscribers; otherwise the fetch is deferred until the next subscriber joins. A no-op while the data is still within its StaleTime window — use Refetch() to force a fetch.

void Invalidate()

Refetch()

Triggers an immediate re-fetch of the entry, bypassing stale-time checks.

void Refetch()