Took a look into hibernate-jcache code today.
It implements an asynchronous cache, meaning it is not aware of transactions itself. A locking mechanism is implemented which wraps every value (the cache entry from hibernate) into an "item" which contains a version and a timestamp.
Looking deeper into the locking implementation, it says that it is working only correctly on a single JVM (Timestamper). The method lockItem returns a lock object, the method lockRegion is doing nothing. Running the unit tests, some paths that deal with concurrent events are uncovered. Since the "locks" are wrappers of values, the locks may get lost when a cache evicts or expires the values.
Is hibernate-jcache meant to work consistently in a clustered environment? Any tests or experiences?
Is the implementation of locking actually needed by a cache implementation, if only targeting a single VM instance?
Depending on what we find out, the documentation should probably get more information about the consistency guarantees / transactional behavior when using JCache based caching.
If it is only working reliably in a single VM this should be documented and maybe the additional overhead of the wrapper objects can be removed.