ObjectCache.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.
When overridden in a derived class, inserts a cache entry into the cache.
Overloads
Set(CacheItem, CacheItemPolicy) |
When overridden in a derived class, inserts the cache entry into the cache as a CacheItem instance, specifying information about how the entry will be evicted. |
Set(String, Object, DateTimeOffset, String) |
When overridden in a derived class, inserts a cache entry into the cache, specifying time-based expiration details. |
Set(String, Object, CacheItemPolicy, String) |
When overridden in a derived class, inserts a cache entry into the cache. |
Remarks
The typical behavior of the Set overload methods is an insert-or-update operation. A cache entry is either inserted as a new entry if the specified entry does not exist, or the cache entry is updated with a new value if it already exists.
Set(CacheItem, CacheItemPolicy)
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
When overridden in a derived class, inserts the cache entry into the cache as a CacheItem instance, specifying information about how the entry will be evicted.
public:
abstract void Set(System::Runtime::Caching::CacheItem ^ item, System::Runtime::Caching::CacheItemPolicy ^ policy);
public abstract void Set (System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy);
abstract member Set : System.Runtime.Caching.CacheItem * System.Runtime.Caching.CacheItemPolicy -> unit
Public MustOverride Sub Set (item As CacheItem, policy As CacheItemPolicy)
Parameters
- item
- CacheItem
The cache item to add.
- policy
- CacheItemPolicy
An object that contains eviction details for the cache entry. This object provides more options for eviction than a simple absolute expiration.
Remarks
If the key for item
does not exist, item
is inserted as a new cache entry. If an item with a key that matches item
exists, the value from item
is used to update or overwrite the value of the existing cache entry.
Applies to
Set(String, Object, DateTimeOffset, String)
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
When overridden in a derived class, inserts a cache entry into the cache, specifying time-based expiration details.
public abstract void Set (string key, object value, DateTimeOffset absoluteExpiration, string regionName = default);
abstract member Set : string * obj * DateTimeOffset * string -> unit
Public MustOverride Sub Set (key As String, value As Object, absoluteExpiration As DateTimeOffset, Optional regionName As String = Nothing)
Parameters
- key
- String
A unique identifier for the cache entry.
- value
- Object
The object to insert.
- absoluteExpiration
- DateTimeOffset
The fixed date and time at which the cache entry will expire.
- regionName
- String
Optional. A named region in the cache to which the cache entry can be added, if regions are implemented. The default value for the optional parameter is null
.
Remarks
If an item that matches key
does not exist in the cache, value
and key
are used to insert as a new cache entry. If an item with a key that matches item
exists, the cache entry is updated or overwritten by using value
.
Applies to
Set(String, Object, CacheItemPolicy, String)
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
- Source:
- ObjectCache.cs
When overridden in a derived class, inserts a cache entry into the cache.
public abstract void Set (string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName = default);
abstract member Set : string * obj * System.Runtime.Caching.CacheItemPolicy * string -> unit
Public MustOverride Sub Set (key As String, value As Object, policy As CacheItemPolicy, Optional regionName As String = Nothing)
Parameters
- key
- String
A unique identifier for the cache entry.
- value
- Object
The object to insert.
- policy
- CacheItemPolicy
An object that contains eviction details for the cache entry. This object provides more options for eviction than a simple absolute expiration.
- regionName
- String
Optional. A named region in the cache to which the cache entry can be added, if regions are implemented. The default value for the optional parameter is null
.
Remarks
This method overload lets you provide more eviction or expiration details than those that are available in time-based absolute expiration.
If an item that matches key
does not exist in the cache, value
and key
are used to insert as a new cache entry. If an item with a key that matches item
exists, the cache entry is updated or overwritten by using value
.