Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java EhCache Write-Behind:写入数据库后删除对象_Java_Hibernate_Caching_Jpa_Ehcache - Fatal编程技术网

Java EhCache Write-Behind:写入数据库后删除对象

Java EhCache Write-Behind:写入数据库后删除对象,java,hibernate,caching,jpa,ehcache,Java,Hibernate,Caching,Jpa,Ehcache,我使用ehcache和write-behind来优化对数据库的写入(通过hibernate)。 我的问题是如何配置ehcache以从缓存中删除刚刚写入db的元素? 我尝试了ttl和空闲时间的几种组合,但都没有成功 我需要它,因为我发现如果元素x是用writer输入的,然后写入db,那么如果我使用cache.get(),那么如果x在缓存中,我会将x作为非托管实体。 我知道我可以将ehcache设置为跨国的,但这是有代价的,而在大多数情况下我并不需要它。另一个原因是我对ehcache及其配置还不熟悉

我使用ehcache和write-behind来优化对数据库的写入(通过hibernate)。 我的问题是如何配置ehcache以从缓存中删除刚刚写入db的元素? 我尝试了ttl和空闲时间的几种组合,但都没有成功

我需要它,因为我发现如果元素x是用writer输入的,然后写入db,那么如果我使用cache.get(),那么如果x在缓存中,我会将x作为非托管实体。 我知道我可以将ehcache设置为跨国的,但这是有代价的,而在大多数情况下我并不需要它。另一个原因是我对ehcache及其配置还不熟悉,现在我希望有一个快速的解决方案

也许我可以使用writer中的cache.remove()删除它们,但是我必须显式地锁定它,这样做的代价是正确的吗

所以,我可以将ehcache配置为在将元素写入数据库时从缓存中删除它们吗

谢谢