CacheClearedListener

CacheClearedListener

Defines a callback method for notifying applications when the Cache is cleared.


Constructor

# new CacheClearedListener(callback)

Parameters:
Name Type Description
callback function

callback is called when when the Cache is cleared

Example
const ncache  = require('ncache-client');

function myClearCallback() {
    //...
 } 

 //Initialize the Cache Cluster 
 let cache = await ncache.CacheManager.getCache("demoCache");
 
 let notificationService = await ncache.cache.getNotificationService();

 // Create Cache Cleared Listener
 let cacheClearedListener = new ncache.CacheClearedListener(myClearCallback);
 await notificationService.addCacheClearedListener(cacheClearedListener);