【发布时间】:2020-12-11 20:10:44
【问题描述】:
是否有与 Hazelcast 的 IMap.values(Predicate) 对应的 Infinispan ?并且可能是非阻塞(异步)?
谢谢。
【问题讨论】:
标签: java infinispan
是否有与 Hazelcast 的 IMap.values(Predicate) 对应的 Infinispan ?并且可能是非阻塞(异步)?
谢谢。
【问题讨论】:
标签: java infinispan
这取决于你想做什么。 Infinispan 扩展了 Java 的 Stream 功能,因此您可以使用 Stream 接口来获取过滤后的值。
例子
//filter by key
cache.values().stream()
.filterKeys(/*set with keys*/)
.forEach(/*do something with the value*/) //or collect()
//filter by key and value
cache.getAdvancedCache().cacheEntrySet().stream()
.filter(entry -> /*check key and value using entry.getKey() or entry.getValue()*/)
.map(StreamMarshalling.entryToValueFunction()) //extract the value only
.forEach(/*do something with the value*/; //or collect()
关于流 here 的 Infinispan 文档。
【讨论】: