NCache 4.6 - Online Documentation

Retrieve Item if a Newer Version Exists in Cache

 
GetIfNewer method can be used to fetch the existing item if a newer version is available in cache. By specifying the current version as an argument of the method, cache returns the appropriate result. If the version specified is less than the one in cache, only then the method returns a new Item else null would be returned.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
            //precondition:┬áitemVersion is saved when item was added or inserted in cache
            string key = "Product:1001";
 
            try
            {
                //saved itemVersion from add or insert item call
                object result = cache.GetIfNewer(key, ref itemVersion);
 
                if (result != null)
                {
                    if (result is Product)
                    {
                        Product product = (Product)result;
                    }
                }
            }
            catch (OperationFailedException ex)
            {
                // handle exception
            }
 
 
See Also