我正在寻找有关如何在 ehcache 中使用此新功能后写缓存的指南/文档/教程?有spring+jpa+ehcache+hibernate的demo吗?
澄清一下,write-behind-cache 意味着每次我们持久化实体时,它都会被写入缓存而不是数据库,对吗?
最佳答案
Ehcache 提供后写缓存的事实不意味着任何使用 Ehcache 的软件,如 Hibernate,都可以在不修改的情况下利用它。来自 Terracotta's Hibernate Integration (请注意,这是一个非独立的帖子,即专业缓存):
Write-Behind Caching
When you think of cache you will arrive at these cache strategies : Read-Through Caching, Write-Through Caching, Write-Behind Caching. Hibernate Second Level cache is Read-Write-Through Cache where if cache miss occurs, entity is read from database and then handed over to cache for susequent access. But H2LC is not Write-Behind caching. With Terracotta's disk persistence and asynchronsous module it would be really efficient for certain use-cases to implement write-behind. Currently Hibernate just directly writes to database. Instead if its modified to write to second level cache and persistent async-database-queue, this would decrease latency and increase throughput dramatically.
换句话说,后写缓存并不是 Hibernate 目前的工作方式(我可能是错的,但我认为这在不久的将来不会改变)。但请随时提出 Jira问题:)
关于java - write behind cache Ehcache新特性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2817296/