MemoryCacheEntryExtensions.SetSlidingExpiration Method

Definition

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 Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions SetSlidingExpiration(this Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions options, TimeSpan offset);

Parameters

offset
TimeSpan

The sliding expiration time.

Returns

The MemoryCacheEntryOptions so that additional calls can be chained.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)