原子序列的监听器
Listener on Atomic Sequence
是否可以在 Atomic Sequence 上监听 Apache Ignite 的 put、get 和 increment?如果没有,还有其他方法可以做这样的事情吗?
无法监听 AtomicSequence 事件,但是,您可以为每个序列更新使用 update 常规缓存,然后监听 EVENT_CACHE_PUT,从而实现相同的功能。
https://ignite.apache.org/docs/latest/data-structures/atomic-sequence
//create an atomic sequence
IgniteAtomicSequence seq = ignite.atomicSequence("seqName", // Sequence name.
0, // Initial value for sequence.
true // Create if it does not exist.
);
// Increment the atomic sequence.
for (int i = 0; i < 20; i++) {
long currentValue = seq.get();
long newValue = seq.incrementAndGet();
//RECORD the sequence value in a regular cache
ignite.getOrCreateCache("myCache").put(ignite.cluster().localNode().id(), newValue)
}
然后按照此处所述收听 EVENT_CACHE_PUT:
https://ignite.apache.org/docs/latest/events/listening-to-events#listening-to-remote-events
是否可以在 Atomic Sequence 上监听 Apache Ignite 的 put、get 和 increment?如果没有,还有其他方法可以做这样的事情吗?
无法监听 AtomicSequence 事件,但是,您可以为每个序列更新使用 update 常规缓存,然后监听 EVENT_CACHE_PUT,从而实现相同的功能。
https://ignite.apache.org/docs/latest/data-structures/atomic-sequence
//create an atomic sequence
IgniteAtomicSequence seq = ignite.atomicSequence("seqName", // Sequence name.
0, // Initial value for sequence.
true // Create if it does not exist.
);
// Increment the atomic sequence.
for (int i = 0; i < 20; i++) {
long currentValue = seq.get();
long newValue = seq.incrementAndGet();
//RECORD the sequence value in a regular cache
ignite.getOrCreateCache("myCache").put(ignite.cluster().localNode().id(), newValue)
}
然后按照此处所述收听 EVENT_CACHE_PUT: https://ignite.apache.org/docs/latest/events/listening-to-events#listening-to-remote-events