<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.12" />

Microsoft.Extensions.Caching.Memory.CacheEntryExtensions

public static class CacheEntryExtensions
Provides extensions methods for ICacheEntry operations.
public static ICacheEntry AddExpirationToken(this ICacheEntry entry, IChangeToken expirationToken)

Expires the cache entry if the given IChangeToken expires.

Fires the given callback after the cache entry is evicted from the cache.

public static ICacheEntry RegisterPostEvictionCallback(this ICacheEntry entry, PostEvictionDelegate callback, object state)

Fires the given callback after the cache entry is evicted from the cache.

public static ICacheEntry SetAbsoluteExpiration(this ICacheEntry entry, TimeSpan relative)

Sets an absolute expiration time, relative to now.

public static ICacheEntry SetAbsoluteExpiration(this ICacheEntry entry, DateTimeOffset absolute)

Sets an absolute expiration date for the cache entry.

public static ICacheEntry SetOptions(this ICacheEntry entry, MemoryCacheEntryOptions options)

Applies the values of an existing MemoryCacheEntryOptions to the entry.

public static ICacheEntry SetPriority(this ICacheEntry entry, CacheItemPriority priority)

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

public static ICacheEntry SetSize(this ICacheEntry entry, long size)

Sets the size of the cache entry value.

public static ICacheEntry SetSlidingExpiration(this ICacheEntry entry, TimeSpan offset)

Sets how long the cache entry can be inactive (for example, not accessed) before it will be removed. This method does not extend the entry lifetime beyond the absolute expiration (if set).

public static ICacheEntry SetValue(this ICacheEntry entry, object value)

Sets the value of the cache entry.