Defines a callback method for notifying applications when a cached item is removed from the Cache.

Namespace: Alachisoft.NCache.Web.Caching
Assembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.3.0.0 (4.3.0.0)

Syntax

C#
[ObsoleteAttribute("This delegate is deprecated. 'Please use CacheDataNotificationCallback(string key, CacheEventArg cacheEventArgs)'", 
	false)]
public delegate void CacheItemRemovedCallback(
	string key,
	Object value,
	CacheItemRemovedReason reason
)
Visual Basic
<ObsoleteAttribute("This delegate is deprecated. 'Please use CacheDataNotificationCallback(string key, CacheEventArg cacheEventArgs)'", 
	false)> 
Public Delegate Sub CacheItemRemovedCallback ( 
	key As String,
	value As Object,
	reason As CacheItemRemovedReason
)
Visual C++
[ObsoleteAttribute(L"This delegate is deprecated. 'Please use CacheDataNotificationCallback(string key, CacheEventArg cacheEventArgs)'", 
	false)]
public delegate void CacheItemRemovedCallback(
	String^ key, 
	Object^ value, 
	CacheItemRemovedReason reason
)

Parameters

key
Type: System..::..String
The index location for the item removed from the cache.
value
Type: System..::..Object
The object item removed from the cache.
reason
Type: Alachisoft.NCache.Web.Caching..::..CacheItemRemovedReason
The reason the item was removed from the cache, as specified by the CacheItemRemovedReason enumeration.

Remarks

Since this handler is invoked every time an item is removed from the Cache, doing a lot of processing inside the handler might have an impact on the performance of the cache and cluster. It is therefore advisable to do minimal processing inside the handler.

Examples

The following example demonstrates how to use the CacheItemRemovedCallback class to notifiy an application when an item is removed from the application's Cache object. You could include this code in a code declaration block in the Web Forms page, or in a page code-behind file.
 Copy imageCopy
static bool itemRemoved = false;
static CacheItemRemovedReason reason;

CacheItemRemovedCallback onRemove = null;

   public void RemovedCallback(string k, object v, CacheItemRemovedReason r)
   {
       itemRemoved = true;
       reason = r;
   }

   public void AddItemToCache(object sender, EventArgs e) 
   {
       itemRemoved = false;
       onRemove = new CacheItemRemovedCallback(this.RemovedCallback);
       if (Cache["Key1"] == null)
           NCache.Cache.Insert("Key1", "Value 1", null, DateTime.Now.AddMinutes(60), TimeSpan.Zero, CacheItemPriority.High, onRemove);
   }

See Also