Struct CachedValue<T>
The result of a cache lookup: whether an entry existed, and its value.
public readonly record struct CachedValue<T> : IEquatable<CachedValue<T>>
Type Parameters
TThe cached value's type.
- Implements
- Inherited Members
Remarks
Found and value are separate on purpose. Both cached lookups legitimately store null — a
caller who is not a member of a team is remembered as not being one. Collapsing "no entry" into
"null value" would send every non-member request back to the store, which is the cost the cache exists to
avoid.
Constructors
CachedValue(bool, T)
The result of a cache lookup: whether an entry existed, and its value.
public CachedValue(bool Found, T Value)
Parameters
FoundboolWhether an entry existed for the key.
ValueTThe cached value. Meaningful only when
Foundis true.
Remarks
Found and value are separate on purpose. Both cached lookups legitimately store null — a
caller who is not a member of a team is remembered as not being one. Collapsing "no entry" into
"null value" would send every non-member request back to the store, which is the cost the cache exists to
avoid.
Properties
Found
Whether an entry existed for the key.
public bool Found { get; init; }
Property Value
Miss
A miss — no entry existed.
public static CachedValue<T> Miss { get; }
Property Value
- CachedValue<T>
Value
The cached value. Meaningful only when Found is true.
public T Value { get; init; }
Property Value
- T
Methods
Hit(T)
A hit carrying value, which may itself be null.
public static CachedValue<T> Hit(T value)
Parameters
valueT
Returns
- CachedValue<T>