NCache 4.6 - Online Documentation

Updating Data with Absolute Expiration

 
In the following example, the insert Operation is used to add/update the absolute expiration time period for an item added to NCache. The expiration is set by using the Calendar class. Also if Absolute Expiration is used, then the NoSlidingExpiration is explicitly declared.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
        try
        {
          // updating absolute expiration of 5 min through Add API.
          cache.Insert(key,product, null, System.DateTime.Now.AddMinutes(5),Cache.NoSlidingExpiration,CacheItemPriority.Default);
 
          //updating Default Absolute expiration with configured value
          cache.Insert(key, product, null, Cache.DefaultAbsolute, Cache.NoSlidingExpiration, CacheItemPriority.Default);
 
          //updating AbsoluteLonger expiration with configured value
          cache.Insert(key, product, null, Cache.DefaultAbsoluteLonger, Cache.NoSlidingExpiration, CacheItemPriority.Default);
        }
        catch(Exception ex)
        {
          // handle exception
        }
 
 
See Also