CacheDataModificationListener

CacheDataModificationListener

Defines a callback method for notifying applications when the Cache is cleared or cache data is modified.


Constructor

# new CacheDataModificationListener(onCacheDataModified, onCacheCleared)

Parameters:
Name Type Description
onCacheDataModified function

callback is called when the Cache data is modified

onCacheCleared function

callback is called when the Cache is cleraed

Example
const ncache = require('ncache-client'); function myDataSourceClear(cacheName) { //.. } function myDataSourceModified(key, event) { //... } //Initialize the Cache Cluster let cache = await ncache.CacheManager.getCache("demoCache"); let messagingService = await cache.getMessagingService(); //Create cache data modification listener let listerner = new ncache.CacheDataModificationListener(myDataSourceModified, myDataSourceClear); await messagingService.addCacheNotificationListener(key, listerner, ncache.EventType.ItemAdded, ncache.EventDataFilter.DataWithMetadata);
JAVASCRIPT
Copied!