CacheExtensions.Set Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Set<TItem>(IMemoryCache, Object, TItem) |
Associates a value with the specified key in the IMemoryCache. |
Set<TItem>(IMemoryCache, Object, TItem, MemoryCacheEntryOptions) |
Associates a cache entry with the specified key and applies the values of an existing MemoryCacheEntryOptions to the created entry. |
Set<TItem>(IMemoryCache, Object, TItem, IChangeToken) |
Associates a cache entry with the specified key that will expire when IChangeToken expires. |
Set<TItem>(IMemoryCache, Object, TItem, DateTimeOffset) |
Creates or overwrites the specified entry in the cache and sets the value with an absolute expiration date. |
Set<TItem>(IMemoryCache, Object, TItem, TimeSpan) |
Associates a cache entry with a specified key that will expire after a specified duration. |
Set<TItem>(IMemoryCache, Object, TItem)
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
Associates a value with the specified key in the IMemoryCache.
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
static TItem Set(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, TItem value);
public static TItem Set<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, TItem value);
static member Set : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item -> 'Item
<Extension()>
Public Function Set(Of TItem) (cache As IMemoryCache, key As Object, value As TItem) As TItem
Type Parameters
- TItem
The type of the object to set.
Parameters
- cache
- IMemoryCache
The IMemoryCache instance this method extends.
- key
- Object
The key of the entry to set.
- value
- TItem
The value to associate with the key.
Returns
The value that was set.
Applies to
Set<TItem>(IMemoryCache, Object, TItem, MemoryCacheEntryOptions)
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
Associates a cache entry with the specified key and applies the values of an existing MemoryCacheEntryOptions to the created entry.
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
static TItem Set(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, TItem value, Microsoft::Extensions::Caching::Memory::MemoryCacheEntryOptions ^ options);
public static TItem Set<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, TItem value, Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions? options);
static member Set : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item * Microsoft.Extensions.Caching.Memory.MemoryCacheEntryOptions -> 'Item
<Extension()>
Public Function Set(Of TItem) (cache As IMemoryCache, key As Object, value As TItem, options As MemoryCacheEntryOptions) As TItem
Type Parameters
- TItem
The type of the object to set.
Parameters
- cache
- IMemoryCache
The IMemoryCache instance this method extends.
- key
- Object
The key of the entry to set.
- value
- TItem
The value to associate with the key.
- options
- MemoryCacheEntryOptions
The existing MemoryCacheEntryOptions instance to apply to the new entry.
Returns
The value that was set.
Applies to
Set<TItem>(IMemoryCache, Object, TItem, IChangeToken)
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
Associates a cache entry with the specified key that will expire when IChangeToken expires.
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
static TItem Set(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, TItem value, Microsoft::Extensions::Primitives::IChangeToken ^ expirationToken);
public static TItem Set<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, TItem value, Microsoft.Extensions.Primitives.IChangeToken expirationToken);
static member Set : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item * Microsoft.Extensions.Primitives.IChangeToken -> 'Item
<Extension()>
Public Function Set(Of TItem) (cache As IMemoryCache, key As Object, value As TItem, expirationToken As IChangeToken) As TItem
Type Parameters
- TItem
The type of the object to set.
Parameters
- cache
- IMemoryCache
The IMemoryCache instance this method extends.
- key
- Object
The key of the entry to set.
- value
- TItem
The value to associate with the key.
- expirationToken
- IChangeToken
The IChangeToken that causes the cache entry to expire.
Returns
The value that was set.
Applies to
Set<TItem>(IMemoryCache, Object, TItem, DateTimeOffset)
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
Creates or overwrites the specified entry in the cache and sets the value with an absolute expiration date.
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
static TItem Set(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, TItem value, DateTimeOffset absoluteExpiration);
public static TItem Set<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, TItem value, DateTimeOffset absoluteExpiration);
static member Set : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item * DateTimeOffset -> 'Item
<Extension()>
Public Function Set(Of TItem) (cache As IMemoryCache, key As Object, value As TItem, absoluteExpiration As DateTimeOffset) As TItem
Type Parameters
- TItem
The type of the value.
Parameters
- cache
- IMemoryCache
A local, in-memory cache whose values are not serialized.
- key
- Object
The entry to create or overwrite.
- value
- TItem
The located value or null
.
- absoluteExpiration
- DateTimeOffset
The expiration time in absolute terms.
Returns
The value that was set.
Applies to
Set<TItem>(IMemoryCache, Object, TItem, TimeSpan)
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
- Source:
- MemoryCacheExtensions.cs
Associates a cache entry with a specified key that will expire after a specified duration.
public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
static TItem Set(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, TItem value, TimeSpan absoluteExpirationRelativeToNow);
public static TItem Set<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, TItem value, TimeSpan absoluteExpirationRelativeToNow);
static member Set : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item * TimeSpan -> 'Item
<Extension()>
Public Function Set(Of TItem) (cache As IMemoryCache, key As Object, value As TItem, absoluteExpirationRelativeToNow As TimeSpan) As TItem
Type Parameters
- TItem
The type of the object to set.
Parameters
- cache
- IMemoryCache
The IMemoryCache instance this method extends.
- key
- Object
The key of the entry to set.
- value
- TItem
The value to associate with the key.
- absoluteExpirationRelativeToNow
- TimeSpan
The duration from now after which the cache entry will expire.
Returns
The value that was set.
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for