【问题标题】:Oracle Coherence - Data change not reflected in cacheOracle Coherence - 数据更改未反映在缓存中
【发布时间】:2010-07-21 05:22:58
【问题描述】:

我在 Java 中使用 Oracle Coherence 缓存,但遇到了问题。当我将某些东西放入缓存(如地图)并使用 get 调用将其取回然后修改对象(例如,向地图添加值)时,修改后的值不会反映在缓存中。即,如果我再次发出 get ,我将得到相同的旧对象。 ehcache 或 dynacache 不会发生这种情况。

我知道我们可以将修改后的地图写回缓存,但我想知道我们是否可以在 coherence config xml 中进行一些配置。

示例代码:

ConcurrentHashMap myMap = new ConcurrentHashMap(); myMap.put("Hello", "World"); cache.put("myMap", myMap); ConcurrentHashMap myExMap = (ConcurrentHashMap)cache.get("myMap"); myExMap.put("Once", "More"); ConcurrentHashMap myFinMap = (ConcurrentHashMap) cache.get("myMap"); System.out.println(myFinMap);

执行后,myFinMap 仍然只有一个条目。

【问题讨论】:

    标签: java caching oracle-coherence


    【解决方案1】:

    也许你每次修改对象都得把它放入缓存中(我猜是因为它是序列化的吧?)

    【讨论】:

      【解决方案2】:

      您必须将对象放回缓存中。从 Coherence 缓存中获取的对象未包装在 Coherence 类中,该类会查找修改并与缓存同步。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-06-19
        • 2018-06-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-11
        • 2017-10-02
        • 1970-01-01
        相关资源
        最近更新 更多