Table of Contents

Class MemoryCacheEntryExtensions

Namespace
LinqToDB.Common.Internal.Cache
Assembly
linq2db.dll
public static class MemoryCacheEntryExtensions
Inheritance
MemoryCacheEntryExtensions

Methods

AddExpirationToken<TKey>(MemoryCacheEntryOptions<TKey>, IChangeToken)

Expire the cache entry if the given IChangeToken expires.

public static MemoryCacheEntryOptions<TKey> AddExpirationToken<TKey>(this MemoryCacheEntryOptions<TKey> options, IChangeToken expirationToken) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

expirationToken IChangeToken

The IChangeToken that causes the cache entry to expire.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

RegisterPostEvictionCallback<TKey>(MemoryCacheEntryOptions<TKey>, PostEvictionDelegate<TKey>)

The given callback will be fired after the cache entry is evicted from the cache.

public static MemoryCacheEntryOptions<TKey> RegisterPostEvictionCallback<TKey>(this MemoryCacheEntryOptions<TKey> options, PostEvictionDelegate<TKey> callback) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

callback PostEvictionDelegate<TKey>

The callback to register for calling after an entry is evicted.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

RegisterPostEvictionCallback<TKey>(MemoryCacheEntryOptions<TKey>, PostEvictionDelegate<TKey>, object?)

The given callback will be fired after the cache entry is evicted from the cache.

public static MemoryCacheEntryOptions<TKey> RegisterPostEvictionCallback<TKey>(this MemoryCacheEntryOptions<TKey> options, PostEvictionDelegate<TKey> callback, object? state) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

callback PostEvictionDelegate<TKey>

The callback to register for calling after an entry is evicted.

state object

The state to pass to the callback.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

SetAbsoluteExpiration<TKey>(MemoryCacheEntryOptions<TKey>, DateTimeOffset)

Sets an absolute expiration date for the cache entry.

public static MemoryCacheEntryOptions<TKey> SetAbsoluteExpiration<TKey>(this MemoryCacheEntryOptions<TKey> options, DateTimeOffset absolute) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

absolute DateTimeOffset

The expiration time, in absolute terms.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

SetAbsoluteExpiration<TKey>(MemoryCacheEntryOptions<TKey>, TimeSpan)

Sets an absolute expiration time, relative to now.

public static MemoryCacheEntryOptions<TKey> SetAbsoluteExpiration<TKey>(this MemoryCacheEntryOptions<TKey> options, TimeSpan relative) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

relative TimeSpan

The expiration time, relative to now.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

SetPriority<TKey>(MemoryCacheEntryOptions<TKey>, CacheItemPriority)

Sets the priority for keeping the cache entry in the cache during a memory pressure tokened cleanup.

public static MemoryCacheEntryOptions<TKey> SetPriority<TKey>(this MemoryCacheEntryOptions<TKey> options, CacheItemPriority priority) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The option on which to set the priority.

priority CacheItemPriority

The CacheItemPriority to set on the option.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

SetSize<TKey>(MemoryCacheEntryOptions<TKey>, long)

Sets the size of the cache entry value.

public static MemoryCacheEntryOptions<TKey> SetSize<TKey>(this MemoryCacheEntryOptions<TKey> options, long size) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The options to set the entry size on.

size long

The size to set on the MemoryCacheEntryOptions<TKey>.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey

SetSlidingExpiration<TKey>(MemoryCacheEntryOptions<TKey>, TimeSpan)

Sets how long the cache entry can be inactive (e.g. not accessed) before it will be removed. This will not extend the entry lifetime beyond the absolute expiration (if set).

public static MemoryCacheEntryOptions<TKey> SetSlidingExpiration<TKey>(this MemoryCacheEntryOptions<TKey> options, TimeSpan offset) where TKey : notnull

Parameters

options MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey>.

offset TimeSpan

The sliding expiration time.

Returns

MemoryCacheEntryOptions<TKey>

The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.

Type Parameters

TKey