NCache 4.6 - Online Documentation

Removing an Item with Specified Item Version

 
A remove method is a basic method which removes the key from cache and returns the removed object to cache. If custom object is added to cache, remove method will return Object. If the item version is different from the one in cache or if the key does not exist  an OperationFailedException will be thrown by NCache.
 
      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.Remove(key, itemVersion);
 
                if (result != null)
                {
                    if (result is Product)
                    {
                        Product product = (Product)result;
                    }
                }
            }
            catch (OperationFailedException ex)
            {
                // handle exception
            }
 

See Also