【问题标题】:How to update values of HashMap fields of objects cached in Coherence?如何更新缓存在 Coherence 中的对象的 HashMap 字段的值?
【发布时间】:2017-07-03 15:42:43
【问题描述】:

有一个带有以下Map字段的java bean:

private Map<String, Long> items;

public Map<String, Long> getItems() {
   return items;
}

public void setItems(Map<String, Long> items) {
   this.items = items;
}

是否有机会使用Coherence Query Language 为缓存在 Coherence 分布式缓存中的对象更新此 items 字段?

类似:

update "order-cache" set items = new HashMap<String, Long>() {{put("001",2L);}} where key()=”1”

【问题讨论】:

    标签: distributed-caching oracle-coherence


    【解决方案1】:

    可以用Guava'sImmutableMap来完成:

    update "order-cache" set items = com.google.common.collect.ImmutableMap.of("001",2L) where key()="1"
    

    此解决方案仅适用于 HashMap 字段中最多 5 个项目的对象。

    【讨论】:

      猜你喜欢
      • 2013-06-19
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2012-02-18
      • 1970-01-01
      • 2020-09-21
      • 2019-09-22
      • 1970-01-01
      相关资源
      最近更新 更多