• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

Method UnRegisterCacheNotification

UnRegisterCacheNotification(CacheEventDescriptor)

Unregisters a cache level event that may have been registered.

Declaration
void UnRegisterCacheNotification(CacheEventDescriptor discriptor)
Parameters
Type Name Description
CacheEventDescriptor discriptor

The descriptor returned when the general event was registered.

Examples

Let us consider you registered an event against a cache

ICache cache = CacheManager.GetCache("demoCache");
CacheEventDescriptor descriptor = cache.MessagingService.RegisterCacheNotification(new CacheDataNotificationCallback(ItemCallback), EventType.ItemAdded, EventDataFilter.None);

Now, Unregister this event by using the CacheEventDescriptor returned by regitering the event

cache.MessagingService.UnRegisterCacheNotification(descriptor);

UnRegisterCacheNotification(String, CacheDataNotificationCallback, EventType)

Unregisters the Alachisoft.NCache.Client.CacheItemUpdatedCallback already registered for the specified key.

Declaration
void UnRegisterCacheNotification(string key, CacheDataNotificationCallback callback, EventType EventType)
Parameters
Type Name Description
System.String key

Unique key to identify the cache item.

CacheDataNotificationCallback callback

The CacheDataNotificationCallback that is invoked when specified EventType is triggered in cache.

EventType EventType

Tells whether the event is to be raised on Item Added, Updated or Removed.

Examples

Example registers and unregisters update and remove notification against a key /// First create an ItemCallback

ItemCallback(string key, CacheEventArg cacheEventArgs)
{
   ...
}

Then register the Key Notification

ICache cache = CacheManager.GetCache("demoCache");
cache.MessagingService.RegisterCacheNotification(key, new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated, EventDataFilter.DataWithMetadata);

Now, Unregister this event.

cache.MessagingService.UnRegisterCacheNotification(key, new CacheDataNotificationCallback(ItemCallback), EventType.ItemUpdated);

UnRegisterCacheNotification(IEnumerable<String>, CacheDataNotificationCallback, EventType)

Unregisters cache notification against specified keys in cache.

Declaration
void UnRegisterCacheNotification(IEnumerable<string> keys, CacheDataNotificationCallback callback, EventType EventType)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> keys

IEnumerable list of keys to identify the cache item.

CacheDataNotificationCallback callback

The CacheDataNotificationCallback that is invoked when specified EventType is triggered against specified keys in cache.

EventType EventType

Tells whether the event is to be raised on Item Added, Updated or Removed.

Examples

Following example demonstrates how to unregister Item added, updated or removed notification against multiple keys in cache. First create an ItemCallback

ItemCallback(string key, CacheEventArg cacheEventArgs)
{
   ...
}

Then register the Key Notification

ICache cache = CacheManager.GetCache("demoCache");

List<string> keys = new List<string>()
{
    "Product0",
    "Product1",
    "Product2"
};

cache.MessagingService.RegisterCacheNotification(keys, new CacheDataNotificationCallback(ItemAdded), EventType.ItemAdded, EventDataFilter.DataWithMetadata);

Now, Unregister this event.

cache.MessagingService.UnRegisterCacheNotification(keys, new CacheDataNotificationCallback(ItemAdded), EventType.ItemAdded);
Back to top Copyright © 2017 Alachisoft