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
entry
ICacheEntry<TKey, TEntry>expirationToken
IChangeTokenThe IChangeToken that causes the cache entry to expire.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>callback
PostEvictionDelegate<TKey>The callback to run after the entry is evicted.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>callback
PostEvictionDelegate<TKey>The callback to run after the entry is evicted.
state
objectThe state to pass to the post-eviction callback.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>absolute
DateTimeOffsetA DateTimeOffset representing the expiration time in absolute terms.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>relative
TimeSpanThe TimeSpan representing the expiration time relative to now.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>options
MemoryCacheEntryOptions<TKey>Set the values of these options on the
entry
.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>The entry to set the priority for.
priority
CacheItemPriorityThe CacheItemPriority to set on the entry.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>size
longThe size to set on the
entry
.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>offset
TimeSpanA TimeSpan representing a sliding expiration.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry
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
entry
ICacheEntry<TKey, TEntry>value
TEntryThe value to set on the
entry
.
Returns
- ICacheEntry<TKey, TEntry>
The ICacheEntry<TKey, TEntity> for chaining.
Type Parameters
TKey
TEntry