Java Hazelcast缓存中是否有类似于比较和设置的内容?
我需要在缓存中将一些对象粘在一起。我从不同hazelcast节点上的队列接收这些对象 例如Java Hazelcast缓存中是否有类似于比较和设置的内容?,java,caching,hazelcast,Java,Caching,Hazelcast,我需要在缓存中将一些对象粘在一起。我从不同hazelcast节点上的队列接收这些对象 例如 Node 1 receives message "message 1. part 1" Node 2 receives message "message 1. part 2" One of the nodes should send to the output full message 1. @sinedsem,最简单的解决方案是: Value oldValue = imap.get(key) Val
Node 1 receives message "message 1. part 1"
Node 2 receives message "message 1. part 2"
One of the nodes should send to the output full message 1.
@sinedsem,最简单的解决方案是:
Value oldValue = imap.get(key)
Value newValue = oldValue;
if (newValue == null) newValue = new Value()
//Either set part1 or part 2 depends on the node
newValue.setPart1(part1)
imap.replace(key, oldValue, newValue)
您也可以检查此示例: