MemoryCache::Set Method (CacheItem, CacheItemPolicy)
Inserts a cache entry into the cache by using a CacheItem instance to supply the key and value for the cache entry.
Assembly: System.Runtime.Caching (in System.Runtime.Caching.dll)
Parameters
- item
- Type: System.Runtime.Caching::CacheItem
An object that represents a cache entry to insert.
- policy
- Type: System.Runtime.Caching::CacheItemPolicy
An object that contains eviction details for the cache entry. This object provides more options for eviction than a simple absolute expiration.
| Exception | Condition |
|---|---|
| ArgumentNullException | item is nullptr. -or- The Key property is nullptr. -or- The Value property is nullptr. |
| ArgumentException | An invalid combination of arguments for the cache entry was passed. This occurs if the following expiration details are set on the policy object for the cache entry:
|
| ArgumentOutOfRangeException | The SlidingExpiration property is set to a value less than Zero. -or- The SlidingExpiration property is set to a value greater than one year. -or- The Priority is not a value of the CacheItemPriority enumeration. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.