gpt4 book ai didi

java - Apache ignite 缓存事件的单个缓存(映射)事件注册

转载 作者:行者123 更新时间:2023-11-30 07:33:58 25 4
gpt4 key购买 nike

我正在寻找一种用ignite注册单个缓存的缓存事件的方法。

可以用此代码注册ignite envorment的所有put事件;

        IgniteBiPredicate<UUID, CacheEvent> lsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
@Override public boolean apply(UUID uuid, CacheEvent evt) {
System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() +
", oldVal=" + evt.oldValue() + ", newVal=" + evt.newValue());

return true; // Continue listening.
}
};
ignite.events().localListen(lsnr, EventType.EVT_CACHE_OBJECT_PUT);

但由于性能原因,我只想为特定 map (缓存)注册缓存事件。否则,我将不得不检查每个事件的缓存名称,这可能会导致系统负载大量且事务量巨大。

感谢您的帮助和指导。

最佳答案

如果你想监听数据更新,连续查询是更好的选择:https://apacheignite.readme.io/docs/continuous-queries

此功能在每个缓存级别上工作,支持正确的事件排序并保证拓扑更改时的交付。

关于java - Apache ignite 缓存事件的单个缓存(映射)事件注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35676028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com