Skip to content

,System.Int32)} ,System.Int32,System.Action{-1})} ,System.Int32,System.Collections.Generic.IEqualityComparer{-0})} ,System.Int32,System.Action{-1},System.Collections.Generic.IEqualityComparer{-0})}

MemoizingMRUCache(Func, int) constructor

Defined in

Type: MemoizingMRUCache Namespace: Splat Assembly: Splat.Logging.dll

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

Overloads

  1. public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize)

  2. public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, Action<TVal> onRelease)

  3. public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, IEqualityComparer<TParam> paramComparer)

  4. public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, Action<TVal>? onRelease, IEqualityComparer<TParam> paramComparer)

1. Overload

public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize)

View source (opens in a new tab)

Summary: Initializes a new instance of the MemoizingMRUCache class.

Parameters

NameTypeDescription
calculationFuncFunc (opens in a new tab)The calculation function used to produce values for missing keys.
maxSizeint (opens in a new tab)The maximum number of entries retained in the cache. Must be > 0.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)Thrown when calculationFunc is null.
System.ArgumentOutOfRangeException (opens in a new tab)Thrown when maxSize is less than or equal to zero.

2. Overload

public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, Action<TVal> onRelease)

View source (opens in a new tab)

Summary: Initializes a new instance of the MemoizingMRUCache class.

Parameters

NameTypeDescription
calculationFuncFunc (opens in a new tab)The calculation function used to produce values for missing keys.
maxSizeint (opens in a new tab)The maximum number of entries retained in the cache. Must be > 0.
onReleaseAction (opens in a new tab)Callback invoked when an entry is evicted or invalidated.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)Thrown when calculationFunc or onRelease is null.
System.ArgumentOutOfRangeException (opens in a new tab)Thrown when maxSize is less than or equal to zero.

3. Overload

public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, IEqualityComparer<TParam> paramComparer)

View source (opens in a new tab)

Summary: Initializes a new instance of the MemoizingMRUCache class.

Parameters

NameTypeDescription
calculationFuncFunc (opens in a new tab)The calculation function used to produce values for missing keys.
maxSizeint (opens in a new tab)The maximum number of entries retained in the cache. Must be > 0.
paramComparerIEqualityComparer (opens in a new tab)Equality comparer for keys.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)Thrown when calculationFunc or paramComparer is null.
System.ArgumentOutOfRangeException (opens in a new tab)Thrown when maxSize is less than or equal to zero.

4. Overload

public MemoizingMRUCache(Func<TParam, object?, TVal> calculationFunc, int maxSize, Action<TVal>? onRelease, IEqualityComparer<TParam> paramComparer)

View source (opens in a new tab)

Summary: Initializes a new instance of the MemoizingMRUCache class.

Parameters

NameTypeDescription
calculationFuncFunc (opens in a new tab)The calculation function used to produce values for missing keys.
maxSizeint (opens in a new tab)The maximum number of entries retained in the cache. Must be > 0.
onReleaseAction? (opens in a new tab)Optional callback invoked when an entry is evicted or invalidated.
paramComparerIEqualityComparer (opens in a new tab)Equality comparer for keys.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)Thrown when calculationFunc or paramComparer is null.
System.ArgumentOutOfRangeException (opens in a new tab)Thrown when maxSize is less than or equal to zero.