Method RegisterCacheNotification
RegisterCacheNotification(CacheDataNotificationCallback, EventType, EventDataFilter)
Registers ItemAdded, ItemUpdate or ItemRemoved events with cache
Declaration
public virtual CacheEventDescriptor RegisterCacheNotification(CacheDataNotificationCallback cacheDataNotificationCallback, EventType eventType, EventDataFilter datafilter)
Parameters
Type | Name | Description |
---|---|---|
CacheDataNotificationCallback | cacheDataNotificationCallback | the CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache. |
Alachisoft.NCache.Runtime.Events.EventType | eventType | Tells whether the event is to be raised on Item Added, Updated or Removed |
Alachisoft.NCache.Runtime.Events.EventDataFilter | datafilter | Tells whether to receive metadata, data with metadata or none when a notification is triggered |
Returns
Type | Description |
---|---|
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
ItemCallback(string key, CacheEventArg e)
{
...
}
Then register the Cache Notification
Cache cache = NCache.InitializeCache("myCache");
CacheEventDescriptor descriptor=cache.RegisterCacheNotification(new CacheDataNotificationCallback(ItemCallback), EventType.ItemAdded, EventDataFilter.None);
RegisterCacheNotification(String, CacheDataNotificationCallback, EventType)
Registers the ItemUpdate or ItemRemoved events for the specified key.
Declaration
public void RegisterCacheNotification(string key, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, EventType eventType)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The cache key used to reference the cache item. |
CacheDataNotificationCallback | selectiveCacheDataNotificationCallback | The CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache |
Alachisoft.NCache.Runtime.Events.EventType | eventType | Tells whether the event is to be raised on Item Added, Updated or Removed |
Examples
First create an ItemCallback
ItemCallback(string key, CacheEventArg e)
{
...
}
Then register the Key Notification
Cache cache = NCache.InitializeCache("myCache");
cache.RegisterCacheNotification(key, new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated);
RegisterCacheNotification(String, CacheDataNotificationCallback, EventType, EventDataFilter)
Registers the ItemUpdate or ItemRemoved events for the specified key.
Declaration
public virtual void RegisterCacheNotification(string key, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, EventType eventType, EventDataFilter datafilter)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The cache key used to reference the cache item. |
CacheDataNotificationCallback | selectiveCacheDataNotificationCallback | The CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache. |
Alachisoft.NCache.Runtime.Events.EventType | eventType | Tells whether the event is to be raised on Item Added, Updated or Removed |
Alachisoft.NCache.Runtime.Events.EventDataFilter | datafilter | Tells whether to receive metadata, data with metadata or none when a notification is triggered |
Examples
First create an ItemCallback
ItemCallback(string key, CacheEventArg e)
{
...
}
Then register the Key Notification
Cache cache = NCache.InitializeCache("myCache");
cache.RegisterCacheNotification(key, new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated, EventDataFilter.None);
RegisterCacheNotification(String[], CacheDataNotificationCallback, EventType)
Registers the ItemUpdate or ItemRemoved events for the specified keys.
Declaration
public void RegisterCacheNotification(string[] keys, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, EventType eventType)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | keys | An array of cache keys used to reference the cache items. |
CacheDataNotificationCallback | selectiveCacheDataNotificationCallback | The CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache. |
Alachisoft.NCache.Runtime.Events.EventType | eventType | Tells whether the event is to be raised on item updated or removed |
Examples
First create an ItemCallback
ItemCallback(string key, CacheEventArg e)
{
...
}
Then register the Key Notification
Cache cache = NCache.InitializeCache("myCache");
string[] keys=new string[size];
cache.RegisterCacheNotification(keys,new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated);
RegisterCacheNotification(String[], CacheDataNotificationCallback, EventType, EventDataFilter)
Registers the ItemUpdate or ItemRemoved events for the specified keys.
Declaration
public virtual void RegisterCacheNotification(string[] keys, CacheDataNotificationCallback selectiveCacheDataNotificationCallback, EventType eventType, EventDataFilter datafilter)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | keys | An array of cache keys used to reference the cache items. |
CacheDataNotificationCallback | selectiveCacheDataNotificationCallback | The CacheDataNotificationCallback that is invoked when an item is added, updated or removed from the cache. |
Alachisoft.NCache.Runtime.Events.EventType | eventType | Tells whether the event is to be raised on item updated or removed |
Alachisoft.NCache.Runtime.Events.EventDataFilter | datafilter | This enum is to describe when registering an event, upon raise how much data is retrieved from cache when the event is raised |
Examples
First create an ItemCallback
ItemCallback(string key, CacheEventArg e)
{
...
}
Then register the Key Notification
Cache cache = NCache.InitializeCache("myCache");
string[] keys=new string[size];
cache.RegisterCacheNotification(keys,new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated, EventDataFilter.None);