Class CacheEntryExtensions
public static class CacheEntryExtensions
- Inheritance
-
CacheEntryExtensions
Methods
AddExpirationToken<TKey, TEntry>(ICacheEntry<TKey, TEntry>, IChangeToken)
Expire the cache entry if the given IChangeToken expires.
public static ICacheEntry<TKey, TEntry> AddExpirationToken<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, IChangeToken expirationToken) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>expirationTokenIChangeTokenThe IChangeToken that causes the cache entry to expire.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
RegisterPostEvictionCallback<TKey, TEntry>(ICacheEntry<TKey, TEntry>, PostEvictionDelegate<TKey>)
The given callback will be fired after the cache entry is evicted from the cache.
public static ICacheEntry<TKey, TEntry> RegisterPostEvictionCallback<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, PostEvictionDelegate<TKey> callback) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>callbackPostEvictionDelegate<TKey>The callback to run after the entry is evicted.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
RegisterPostEvictionCallback<TKey, TEntry>(ICacheEntry<TKey, TEntry>, PostEvictionDelegate<TKey>, object?)
The given callback will be fired after the cache entry is evicted from the cache.
public static ICacheEntry<TKey, TEntry> RegisterPostEvictionCallback<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, PostEvictionDelegate<TKey> callback, object? state) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>callbackPostEvictionDelegate<TKey>The callback to run after the entry is evicted.
stateobjectThe state to pass to the post-eviction callback.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetAbsoluteExpiration<TKey, TEntry>(ICacheEntry<TKey, TEntry>, DateTimeOffset)
Sets an absolute expiration date for the cache entry.
public static ICacheEntry<TKey, TEntry> SetAbsoluteExpiration<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, DateTimeOffset absolute) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>absoluteDateTimeOffsetA DateTimeOffset representing the expiration time in absolute terms.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetAbsoluteExpiration<TKey, TEntry>(ICacheEntry<TKey, TEntry>, TimeSpan)
Sets an absolute expiration time, relative to now.
public static ICacheEntry<TKey, TEntry> SetAbsoluteExpiration<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, TimeSpan relative) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>relativeTimeSpanThe TimeSpan representing the expiration time relative to now.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetOptions<TKey, TEntry>(ICacheEntry<TKey, TEntry>, MemoryCacheEntryOptions<TKey>)
Applies the values of an existing MemoryCacheEntryOptions<TKey> to the entry.
public static ICacheEntry<TKey, TEntry> SetOptions<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, MemoryCacheEntryOptions<TKey> options) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>optionsMemoryCacheEntryOptions<TKey>Set the values of these options on the
entry.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetPriority<TKey, TEntry>(ICacheEntry<TKey, TEntry>, CacheItemPriority)
Sets the priority for keeping the cache entry in the cache during a memory pressure tokened cleanup.
public static ICacheEntry<TKey, TEntry> SetPriority<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, CacheItemPriority priority) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>The entry to set the priority for.
priorityCacheItemPriorityThe CacheItemPriority to set on the entry.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetSize<TKey, TEntry>(ICacheEntry<TKey, TEntry>, long)
Sets the size of the cache entry value.
public static ICacheEntry<TKey, TEntry> SetSize<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, long size) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>sizelongThe size to set on the
entry.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetSlidingExpiration<TKey, TEntry>(ICacheEntry<TKey, TEntry>, 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 ICacheEntry<TKey, TEntry> SetSlidingExpiration<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, TimeSpan offset) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>offsetTimeSpanA TimeSpan representing a sliding expiration.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry
SetValue<TKey, TEntry>(ICacheEntry<TKey, TEntry>, TEntry)
Sets the value of the cache entry.
public static ICacheEntry<TKey, TEntry> SetValue<TKey, TEntry>(this ICacheEntry<TKey, TEntry> entry, TEntry value) where TKey : notnull
Parameters
entryICacheEntry<TKey, TEntry>valueTEntryThe value to set on the
entry.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKeyTEntry