Construtor
# novo CacheDataModificationListener(onCacheDadosModificados, onCacheLimpo)
parâmetros:
Nome | Formato | Descrição |
---|---|---|
onCacheDataModified |
função | callback é chamado quando os dados do Cache são modificados |
onCacheCleared |
função | callback é chamado quando o Cache é limpo |
Exemplo
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);