java - Infinispan 等效于 IMap.values(Predicate)
问题描述
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()
关于流的 Infinispan 文档在这里。
推荐阅读
- c++ - 有什么方法可以使用在一个函数中定义的 const 变量可以被 C++ 中同一程序中的其他函数使用
- java - 杰克逊:我怎么能忽略getter但解析setter?
- java - 在 /actuator/health 上配置超时
- javascript - 文档读取计数(如果不存在)
- r - 如何转换我的代码以提高速度(for循环)
- java - Tesseract 4.5 为相同的图像结构返回多个结果
- postgresql - 我可以在 postgres 中构造一个更新查询,其中要更新的列嵌套在一个案例中吗?
- matlab - Matlab中有一个函数可以创建矩阵,其中每个元素是矩阵索引的相同函数?
- vue.js - 如果我强制重新渲染,Vuetify 数据表错误会解决
- python-3.x - id 级别的条件复制