Class CachedValue
Cached value wrapper that preserves type information for proper deserialization. Must be public for System.Text.Json serialization when using distributed caching.
[JsonConverter(typeof(CachedValueJsonConverter))]
public sealed class CachedValue
- Inheritance
-
CachedValue
- Inherited Members
- Extension Methods
Remarks
The Value property is typed as object? to support polymorphic caching.
The CachedValueJsonConverter handles serialization by writing the runtime type
and deserialization by reading TypeName to reconstruct the correct type.
This is critical for HybridCache L2 (distributed) serialization round-trips.
Properties
HasExecuted
Gets a value indicating whether the handler has been executed.
public bool HasExecuted { get; init; }
Property Value
ShouldCache
Gets a value indicating whether the value should be cached.
public bool ShouldCache { get; init; }
Property Value
TagStamps
Gets the version stamp each of this entry's tags had at the moment this entry was written, or null for an entry written before this mechanism existed.
public IReadOnlyDictionary<string, string>? TagStamps { get; init; }
Property Value
Remarks
These are write-time stamps, frozen once and never refreshed: an entry is written once and read many times, so the value baked in here is simply the tag's version at the moment of the write, which is already known then. A read compares each of these against the tag's current stamp (fetched fresh from the tracker, never cached alongside the entry) to decide whether the entry has since been invalidated.
A tag with no stamp yet in the tracker's backend (a tag nothing has ever invalidated) and an entry with no recorded stamp for one of its own tags (typically an entry serialized before this property existed) are different conditions and must not be treated the same way: the former has nothing to compare against because nothing has happened to the tag yet, and is safe to treat as still valid; the latter has nothing to compare against because the entry itself is missing the information needed to prove validity, and must be treated as invalidated. Read this dictionary as absent-means-unprovable, not absent-means-valid.
TypeName
Gets the assembly-qualified type name for deserialization.
public string? TypeName { get; init; }
Property Value
Value
Gets the cached value object.
public object? Value { get; init; }