Open sandboxFocus

Property SizeCalculator

SizeCalculator

Gets or sets a delegate that receives the object being cached and returns its size, for use in the Size property of the MemoryCacheEntryOptions object. This allows to enforce a size limit on the MemoryCache (see SizeLimit). The default value is a delegate returning the constant 1. This property is ignored if Serializer has a non-null value, because in this case the size is the number of bytes in the serialized item.

Declaration
public Func<object?, long> SizeCalculator { get; init; }
Property Value
Type Description
Func<object, long>