Hello all,
I have a question for my understanding regarding the concurrency strategies of the second level cache. In Java Persistence with Hibernate the description of the nonstrict-read-write cache says "Makes no guarantee of consistency between the cache and the database. If there is a possibility of concurrent access to the same entity, you should configure a sufficiently short expiry timeout. Otherwise, you may read stale data from the cache."
Maybe I am missing a very basic concept but could somebody think of an example scenario in which I will get this trouble. I mean, if I change an entity that is held by the 2nd level cache the tablespace gets invalidated and the next access for this object triggers a database hit. Where is the mistake in my thinking?
Or maybe someone has a link to another page describing this problem. I am playing with this for quite some time now and I was not able to create sample code, that has read old data from the cache.
I appreciate every help. Thanks in advance.
Greets,
Patrick
|