MemoryCache.Set Method (String, Object, CacheItemPolicy, String)
Inserts a cache entry into the cache by using a key and a value and eviction.
Assembly: System.Runtime.Caching (in System.Runtime.Caching.dll)
public override void Set( string key, object value, CacheItemPolicy policy, string regionName = null )
A unique identifier for the cache entry to insert.
The data for the cache entry.
An object that contains eviction details for the cache entry. This object provides more options for eviction than a simple absolute expiration.
key is null.
value is null
The callback reference that was passed to the helper method in the UpdateCallback property is null.
regionName is not null.
Like other Set method overloads, the method always puts a cache value in the cache, regardless whether a matching entry already exists. If the specified entry does not exist in the cache, a new cache entry is inserted. If the specified entry exists, it is updated.
Removing an entry triggers any associated change monitors. If the removed item was associated with a CacheItemUpdateCallback object or CacheItemRemovedCallback object, the reason for removal that is passed to the callbacks is contained in the Removed property.
Available since 4.0