NCache 4.6 - Online Documentation

Retrieving Cached Item with Specific Version

 
A cached item can be retrieved by specifying version. In case of a mismatch of version, null is returned. In this example, key and  the previously saved item version of that key needs to be specified to fetch the cached object.
 
      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
            try
            {
                string key = "Product:1001";
 
                //saved itemVersion from add or insert item call
                CacheItem result = cache.GetCacheItem(key, ref itemVersion);
 
                if (result.Value != null)
                {
                    if (result.Value is Product)
                    {
                        Product product = (Product)result.Value;
                    }
                }
            }
            catch (OperationFailedException ex)
            {
                // handle exception
            }
 
 
See Also