Registers ItemAdded, ItemUpdate or ItemRemoved events with 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#
public override CacheEventDescriptor RegisterCacheNotification(
	CacheDataNotificationCallback cacheDataNotificationCallback,
	EventType eventType,
	EventDataFilter datafilter
)
Visual Basic
Public Overrides Function RegisterCacheNotification ( 
	cacheDataNotificationCallback As CacheDataNotificationCallback,
	eventType As EventType,
	datafilter As EventDataFilter
) As CacheEventDescriptor
Visual C++
public:
virtual CacheEventDescriptor^ RegisterCacheNotification(
	CacheDataNotificationCallback^ cacheDataNotificationCallback, 
	EventType eventType, 
	EventDataFilter datafilter
) override

Parameters

cacheDataNotificationCallback
Type: Alachisoft.NCache.Web.Caching..::..CacheDataNotificationCallback
the CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache.
eventType
Type: Alachisoft.NCache.Runtime.Events..::..EventType
Tells whether the event is to be raised on Item Added, Updated or Removed
datafilter
Type: Alachisoft.NCache.Runtime.Events..::..EventDataFilter
Tells whether to receive metadata, data with metadata or none when a notification is triggered

Return Value

Type: CacheEventDescriptor

Remarks

Client application can show interest in receiving events if an item is added, update or removed from the cache. As soon as the item is added, updated or removed from the cache, the client application is notified and actions can be taken accordingly.

Examples

First create an ItemCallback
 Copy imageCopy
ItemCallback(string key, CacheEventArg e)
{
   ...
}
Then register the Cache Notification
 Copy imageCopy
Cache cache = NCache.InitializeCache("myCache");
CacheEventDescriptor descriptor=cache.RegisterCacheNotification(new CacheDataNotificationCallback(ItemCallback), EventType.ItemAdded, EventDataFilter.None);

See Also