Try Playground
Show / Hide Table of Contents

Method RegisterCacheNotification

RegisterCacheNotification(String, CacheDataNotificationCallback, EventType, EventDataFilter)

Registers cache notification EventType of type item added, updated or removed against specified key in cache.

Declaration
void RegisterCacheNotification(string key, CacheDataNotificationCallback callback, EventType eventType, EventDataFilter eventDataFilter = EventDataFilter.None)
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 against specified key in cache.

EventType eventType

States whether the event is to be raised on item added, updated or removed.

EventDataFilter eventDataFilter

States whether to receive metadata, data with metadata or none when a notification is triggered.

Examples

The following example demonstrates how to register item added, updated or removed notification against a key in cache. 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);

RegisterCacheNotification(IEnumerable<String>, CacheDataNotificationCallback, EventType, EventDataFilter)

Registers cache notification EventType of type item added, updated or removed against specified keys in cache.

Declaration
void RegisterCacheNotification(IEnumerable<string> keys, CacheDataNotificationCallback callback, EventType eventType, EventDataFilter eventDataFilter = EventDataFilter.None)
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.

EventDataFilter eventDataFilter

Tells whether to receive metadata, data with metadata or none when a notification is triggered.

Remarks

Only single notification is registered against duplicate keys in keys.

Examples

The following example demonstrates how to register 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(ItemCallback), EventType.ItemAdded, EventDataFilter.DataWithMetadata);

RegisterCacheNotification(CacheDataNotificationCallback, EventType, EventDataFilter)

Registers cache notification EventType of type item added, updated or removed against specified keys in cache.

Declaration
CacheEventDescriptor RegisterCacheNotification(CacheDataNotificationCallback callback, EventType eventType, EventDataFilter eventDataFilter = EventDataFilter.None)
Parameters
Type Name Description
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.

EventDataFilter eventDataFilter

Tells whether to receive metadata, data with metadata or none when a notification is triggered.

Returns
Type Description
CacheEventDescriptor

Instance of CacheEventDescriptor required to

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

The following example demonstrates how to register Item added, updated or removed notification in cache. First, create an ItemCallback.

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

Then, register the Cache Notification.

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

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top