Inserts an object into the System.Web.Caching.Cache with dependencies and expiration policies.
- key
- The cache key used to reference the object.
- value
- The object to be inserted in the cache.
- dependencies
- The file or cache key dependencies for the inserted object. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this parameter contains null.
- absoluteExpiration
- The time at which the inserted object expires and is removed from the cache. To avoid possible issues with local time such as changes from standard time to daylight saving time, use DateTime.UtcNow rather than DateTime.Now for this parameter value. If you are using absolute expiration, the slidingExpiration parameter must be Cache.NoSlidingExpiration.
- slidingExpiration
- The interval between the time the inserted object is last accessed and the time at which that object expires. If this value is the equivalent of 20 minutes, the object will expire and be removed from the cache 20 minutes after it was last accessed. If you are using sliding expiration, the absoluteExpiration parameter must be Cache.NoAbsoluteExpiration.
This method will overwrite an existing Cache item with the same key parameter.
If the slidingExpiration parameter is set to Cache.NoSlidingExpiration, sliding expiration is disabled. If you set the slidingExpiration parameter to greater than TimeSpan.Zero, the absoluteExpiration parameter is set to DateTime.Now plus the value contained in the slidingExpiration parameter. If the item is requested from the cache before the amount of time specified by the absoluteExpiration parameter, the item will be placed in the cache again, and absoluteExpiration will again be set to DateTime.Now plus the value contained in the slidingExpiration parameter. If the item is not requested from the cache before the date in the absoluteExpiration parameter, the item is removed from the cache. . The item added to the cache using this overload of the insert method is inserted with a priority of CacheItemPriority.Default.