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
optionsMemoryCacheEntryOptions<TKey>expirationTokenIChangeTokenThe 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
optionsMemoryCacheEntryOptions<TKey>callbackPostEvictionDelegate<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
optionsMemoryCacheEntryOptions<TKey>callbackPostEvictionDelegate<TKey>The callback to register for calling after an entry is evicted.
stateobjectThe 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
optionsMemoryCacheEntryOptions<TKey>absoluteDateTimeOffsetThe 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
optionsMemoryCacheEntryOptions<TKey>relativeTimeSpanThe 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
optionsMemoryCacheEntryOptions<TKey>The option on which to set the priority.
priorityCacheItemPriorityThe 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
optionsMemoryCacheEntryOptions<TKey>The options to set the entry size on.
sizelongThe 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
optionsMemoryCacheEntryOptions<TKey>offsetTimeSpanThe sliding expiration time.
Returns
- MemoryCacheEntryOptions<TKey>
The MemoryCacheEntryOptions<TKey> so that additional calls can be chained.
Type Parameters
TKey