Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Microsoft.​Extensions.​Caching.​Memory.​CacheEntryExtensions
Assembly: Microsoft.Extensions.Caching.Abstractions
Inheritance: object → CacheEntryExtensions
Provides extensions methods for <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> operations.
Methods
public static
ICacheEntry
AddExpirationToken​(ICacheEntry entry,
Primitives.​IChangeToken expirationToken)
Expires the cache entry if the given <see cref="T:Microsoft.Extensions.Primitives.IChangeToken" /> expires.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
expirationToken
The <see cref="T:Microsoft.Extensions.Primitives.IChangeToken" /> that causes the cache entry to expire.
public static
ICacheEntry
RegisterPostEvictionCallback​(ICacheEntry entry,
PostEvictionDelegate callback)
Fires the given callback after the cache entry is evicted from the cache.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
callback
The callback to run after the entry is evicted.
public static
ICacheEntry
RegisterPostEvictionCallback​(ICacheEntry entry,
PostEvictionDelegate callback,
object state)
Fires the given callback after the cache entry is evicted from the cache.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
callback
The callback to run after the entry is evicted.
state
The state to pass to the post-eviction callback.
public static
ICacheEntry
SetAbsoluteExpiration​(ICacheEntry entry,
System.​DateTimeOffset absolute)
Sets an absolute expiration date for the cache entry.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
absolute
A <see cref="T:System.DateTimeOffset" /> representing the expiration time in absolute terms.
public static
ICacheEntry
SetAbsoluteExpiration​(ICacheEntry entry,
System.​TimeSpan relative)
Sets an absolute expiration time, relative to now.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
relative
The <see cref="T:System.TimeSpan" /> representing the expiration time relative to now.
public static
ICacheEntry
SetOptions​(ICacheEntry entry,
MemoryCacheEntryOptions options)
Applies the values of an existing <see cref="T:Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions" /> to the entry.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
options
Set the values of these options on the <paramref name="entry" /> .
public static
ICacheEntry
SetPriority​(ICacheEntry entry,
CacheItemPriority priority)
Sets the priority for keeping the cache entry in the cache during a memory pressure tokened cleanup.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The entry to set the priority for.
priority
The <see cref="T:Microsoft.Extensions.Caching.Memory.CacheItemPriority" /> to set on the entry.
public static
ICacheEntry
SetSize​(ICacheEntry entry,
long size)
Sets the size of the cache entry value.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
size
The size to set on the <paramref name="entry" /> .
public static
ICacheEntry
SetSlidingExpiration​(ICacheEntry entry,
System.​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).
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
offset
A <see cref="T:System.TimeSpan" /> representing a sliding expiration.
public static
ICacheEntry
SetValue​(ICacheEntry entry,
object value)
Sets the value of the cache entry.
Returns The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> for chaining.
entry
The <see cref="T:Microsoft.Extensions.Caching.Memory.ICacheEntry" /> .
value
The value to set on the <paramref name="entry" /> .
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object