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 written 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With