Table of Contents

Struct CachedValue<T>

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

The result of a cache lookup: whether an entry existed, and its value.

public readonly record struct CachedValue<T> : IEquatable<CachedValue<T>>

Type Parameters

T

The 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

Found bool

Whether an entry existed for the key.

Value T

The cached value. Meaningful only when Found is 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

bool

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

value T

Returns

CachedValue<T>