Class MemoryCacheEntryExtensions
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>expirationToken
IChangeTokenThe 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>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>callback
PostEvictionDelegate<TKey>The callback to register for calling after an entry is evicted.
state
objectThe 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>absolute
DateTimeOffsetThe 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>relative
TimeSpanThe 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
CacheItemPriorityThe 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
longThe 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>offset
TimeSpanThe sliding expiration time.
Returns
- MemoryCacheEntryOptions<TKey>
The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.
Type Parameters
TKey