Table of Contents

Struct CachedItemRemovalEvent<TKey, TValue>

Namespace
LfrlAnvil.Caching
Assembly
LfrlAnvil.Core.dll

A lightweight representation of an event that signals removal of an entry from an ICache<TKey, TValue>.

public readonly record struct CachedItemRemovalEvent<TKey, TValue> : IEquatable<CachedItemRemovalEvent<TKey, TValue>>

Type Parameters

TKey

Cache entry's key (identifier) type.

TValue

Cache entry's value type.

Implements
Inherited Members
Extension Methods

Constructors

CachedItemRemovalEvent(TKey, TValue, TValue?, bool)

A lightweight representation of an event that signals removal of an entry from an ICache<TKey, TValue>.

public CachedItemRemovalEvent(TKey Key, TValue Removed, TValue? Replacement, bool IsReplaced)

Parameters

Key TKey

Key of an entry associated with this event.

Removed TValue

Value of a removed entry associated with this event.

Replacement TValue

Value of an entry that replaced the Removed value associated with this event.

IsReplaced bool

Indicates whether or not this event contains a Replacement value.

Properties

IsReplaced

Indicates whether or not this event contains a Replacement value.

public bool IsReplaced { get; init; }

Property Value

bool

Key

Key of an entry associated with this event.

public TKey Key { get; init; }

Property Value

TKey

Removed

Value of a removed entry associated with this event.

public TValue Removed { get; init; }

Property Value

TValue

Replacement

Value of an entry that replaced the Removed value associated with this event.

public TValue? Replacement { get; init; }

Property Value

TValue

Methods

CreateRemoved(TKey, TValue)

Creates a new CachedItemRemovalEvent<TKey, TValue> instance.

[Pure]
public static CachedItemRemovalEvent<TKey, TValue> CreateRemoved(TKey key, TValue removed)

Parameters

key TKey

Key of the removed cache entry.

removed TValue

Value of the removed cache entry.

Returns

CachedItemRemovalEvent<TKey, TValue>

CachedItemRemovalEvent<TKey, TValue> instance without a Replacement value.

CreateReplaced(TKey, TValue, TValue)

Creates a new CachedItemRemovalEvent<TKey, TValue> instance with Replacement value.

[Pure]
public static CachedItemRemovalEvent<TKey, TValue> CreateReplaced(TKey key, TValue removed, TValue replacement)

Parameters

key TKey

Key of the cache entry.

removed TValue

Removed value associated with the key.

replacement TValue

Value associated with the key which replaced the removed value.

Returns

CachedItemRemovalEvent<TKey, TValue>

CachedItemRemovalEvent<TKey, TValue> instance with a Replacement value.