MemoryCacheEntryExtensions Class

Namespace
Microsoft.Extensions.Caching.Memory
Assemblies
  • Microsoft.Extensions.Caching.Abstractions

Syntax

public class MemoryCacheEntryExtensions
class Microsoft.Extensions.Caching.Memory.MemoryCacheEntryExtensions

Methods

AddExpirationToken(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, Microsoft.Extensions.Primitives.IChangeToken)

Expire the cache entry if the given Microsoft.Extensions.Primitives.IChangeToken expires.

Arguments:
Return type:

Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions

public static MemoryCacheEntryOptions AddExpirationToken(this MemoryCacheEntryOptions options, IChangeToken expirationToken)
RegisterPostEvictionCallback(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, Microsoft.Extensions.Caching.Memory.PostEvictionDelegate)

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

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions RegisterPostEvictionCallback(this MemoryCacheEntryOptions options, PostEvictionDelegate callback)
RegisterPostEvictionCallback(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, Microsoft.Extensions.Caching.Memory.PostEvictionDelegate, System.Object)

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

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions RegisterPostEvictionCallback(this MemoryCacheEntryOptions options, PostEvictionDelegate callback, object state)
SetAbsoluteExpiration(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, System.DateTimeOffset)

Sets an absolute expiration date for the cache entry.

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions SetAbsoluteExpiration(this MemoryCacheEntryOptions options, DateTimeOffset absolute)
SetAbsoluteExpiration(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, System.TimeSpan)

Sets an absolute expiration time, relative to now.

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions SetAbsoluteExpiration(this MemoryCacheEntryOptions options, TimeSpan relative)
SetPriority(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, Microsoft.Extensions.Caching.Memory.CacheItemPriority)

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

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions SetPriority(this MemoryCacheEntryOptions options, CacheItemPriority priority)
SetSlidingExpiration(Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions, System.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).

Return type:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions
public static MemoryCacheEntryOptions SetSlidingExpiration(this MemoryCacheEntryOptions options, TimeSpan offset)