gpt4 book ai didi

java - Oracle Coherence - 数据更改未反射(reflect)在缓存中

转载 作者:行者123 更新时间:2023-12-01 16:03:12 25 4
gpt4 key购买 nike

我正在将 Oracle Coherence 缓存与 Java 结合使用,但遇到了问题。当我将某些内容放入缓存(例如 map )并使用 get 调用取回它,然后修改该对象(例如,向 map 添加一个值)时,修改后的值不会反射(reflect)在缓存中。也就是说,如果我再次发出 get 请求,我将得到相同的旧对象。 ehcache 或 dynacache 不会出现这种情况。

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

示例代码:

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

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

最佳答案

也许每次修改对象时都必须将其放入缓存中(我猜是因为它是序列化的?)

关于java - Oracle Coherence - 数据更改未反射(reflect)在缓存中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3296496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com