NCache 4.6 - Online Documentation

Adding New Item with Absolute Expiration

 
In the following example, the Add Operation is used to specify an absolute expiration time period for a cache item in NCache.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
      try
        {
 
          //adding absolute expiration of 5 min through Add API.
          cache.Add(key,product, null, System.DateTime.Now.AddMinutes(5),Cache.NoSlidingExpiration,CacheItemPriority.Default);
 
            // adding Default Absolute expiration with configured value
            cache.Add(key, product, null, Cache.DefaultAbsolute, Cache.NoSlidingExpiration, CacheItemPriority.Default);
 
            // adding AbsoluteLonger expiration with configured value
            cache.Add(key, product, null, Cache.DefaultAbsoluteLonger, Cache.NoSlidingExpiration, CacheItemPriority.Default);
 
        }
        catch (Exception ex)
        {
            // handle exception
        }
 
 
See Also