Infinispan等效于IMap.valuesPredicate

问题描述

Infinispan是否有与Hazelcast相同的IMap.values(Predicate)?还有可能是非阻塞(异步)?

谢谢。

解决方法

这取决于您要执行的操作。 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文档。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...