开发者

write behind cache Ehcache new feature?

开发者 https://www.devze.com 2022-12-30 13:02 出处:网络
i looking for guide/document/tutorial on how to use this new feature write-behind-cache in ehcache? Is there any demo in spring+jpa+ehcache+hibernate?

i looking for guide/document/tutorial on how to use this new feature write-behind-cache in ehcache? Is there any demo in spring+jpa+ehcache+hibernate?

just to clariyfing, write-behind-cache mean each time we persist entity, it will be writte开发者_开发百科n into cache rather than into database correct?


The fact that Ehcache offers Write-Behind Caching does NOT mean that any piece of software using Ehcache, like Hibernate, can leverage it without modification. From Terracotta's Hibernate Integration (note that this is a non independent post i.e. pro caching):

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.

In other words, write-behind caching is just not how Hibernate currently works (and I may be wrong but I don't think this is going to change in a a near future). But feel free to raise a Jira issue :)


http://www.infoq.com/news/2010/05/ehcache-2.0

Ehcache 2.0 introduces write-through and write-behind caching. Write-through caching pattern is used by the applications to write data to the cache which causes writes to an underlying resource (e.g. a database). The cache acts as a facade to the underlying resource. Write-behind caching pattern uses the same client API, but the write happens asynchronously. The write-behind caching feature, supported as part of the new Ehcache API, works with asynchronous batching of updates to the database.


I can't help you, just thought I'd mention GigaSpaces.

0

精彩评论

暂无评论...
验证码 换一张
取 消