NCache 4.6 - Online Documentation

Removing Item with Registered Callback Method

 
NCache provides AsyncItemRemovedCallback to be used in order to receive notification upon completion of item removal.  In this example you need to register the above mentioned callback with NCache to receive a notification.
 
      To utilize the API, include the following namespace in your application: Alachisoft.NCache.Web.Caching.
 
        string key= "Product:1001";
 
        try
        {
            cache.RemoveAsync(key, new AsyncItemRemovedCallback(OnItemRemoved), DSWriteOption.None, null);
        }
        catch (Exception ex)
        {
            // handle exception
        }
 
        //Create a callback
        public static void OnItemRemove(string key, object status)
        {
          if (status.ToString().Equals("Success"))
          {   
//do something
          }
          if (status.ToString().Equals("Failure"))
          {   
//do something
          }
          if (status is Exception)
          {   
//do something
          } 
        }
 
 
See Also