Infinispan的相当于IMap.values(Predicate)的方法是什么?

huangapple go评论66阅读模式
英文:

Infinispan equivalent of IMap.values(Predicate)

问题

在Infinispan中是否有类似Hazelcast的IMap.values(Predicate)功能?并且可能支持非阻塞(异步)操作?

谢谢。

英文:

Is there an equivalent of Hazelcast's IMap.values(Predicate) for Infinispan ? And possibly non-blocking (async) ?

Thanks.

答案1

得分: 2

根据您所尝试的操作而定。Infinispan 扩展了 Java 的 Stream 功能,因此您可以使用 Stream 接口来获取经过筛选的值。

示例:

// 按键筛选
cache.values().stream()
    .filterKeys(/*使用键集*/)
    .forEach(/*对值执行某些操作*/) // 或者使用 collect()

// 按键和值筛选
cache.getAdvancedCache().cacheEntrySet().stream()
    .filter(entry -> /*使用 entry.getKey() 或 entry.getValue() 检查键和值*/)
    .map(StreamMarshalling.entryToValueFunction()) // 仅提取值
    .forEach(/*对值执行某些操作*/) // 或者使用 collect()

有关 Infinispan 流的文档可以在此处找到。

英文:

It depends on what you trying to do. Infinispan extends Java's Stream functionality so you can use the Stream interface to get the filtered values.

Examples

//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 documentation about streams here.

huangapple
  • 本文由 发表于 2020年8月23日 02:37:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/63539811.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定