ObjectCache.Set ObjectCache.Set ObjectCache.Set ObjectCache.Set Method

Definition

When overridden in a derived class, inserts a cache entry into the cache.

Overloads

Set(CacheItem, CacheItemPolicy) Set(CacheItem, CacheItemPolicy) Set(CacheItem, CacheItemPolicy) 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) Set(String, Object, DateTimeOffset, String) 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) Set(String, Object, CacheItemPolicy, String) 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) Set(CacheItem, CacheItemPolicy) Set(CacheItem, CacheItemPolicy) 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.

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 CacheItem CacheItem CacheItem

The cache item to add.

policy
CacheItemPolicy CacheItemPolicy CacheItemPolicy 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.

Set(String, Object, DateTimeOffset, String) Set(String, Object, DateTimeOffset, String) Set(String, Object, DateTimeOffset, String)

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 = null);
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 = null)

Parameters

key
String String String String

A unique identifier for the cache entry.

value
Object Object Object Object

The object to insert.

absoluteExpiration
DateTimeOffset DateTimeOffset DateTimeOffset DateTimeOffset

The fixed date and time at which the cache entry will expire.

regionName
String String String 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.

Set(String, Object, CacheItemPolicy, String) Set(String, Object, CacheItemPolicy, String) Set(String, Object, CacheItemPolicy, String)

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 = null);
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 = null)

Parameters

key
String String String String

A unique identifier for the cache entry.

value
Object Object Object Object

The object to insert.

policy
CacheItemPolicy CacheItemPolicy CacheItemPolicy 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 String String 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.

Applies to