jsr107/jsr107spec — Issue #44: Clarify Semantics when read through is enabled
Author: yannis666
Created: 2011-11-23 18:49:39+00:00
State: open

There has been a discussion of this on the google group that was never resolved.

When the cache loader is enabled there needs to be clarity on when exactly the loader should be invoked.
An example of this is `cache.containsKey(key)`. For a static “back end” store, I believe the following should be an invariant:

cache.containsKey(key) && (cache.get(key) != null)

the truth value should always be the same regardless of the order of the calls.

If we go this route, then any access to an entry where the entry is not in the cache will need to invoke the loader. The choices

An alternative view may be that only a strict set of calls can invoke the loader - my problem with that is that in that case different ordering of calls can lead to different results.

This leads to a fundamental issue of what a cache with read through means - if it is strictly an optimization adapter to the “real” store, then its semantics should never differ from queries against the “real” store.

I added an [issue in spec document](https://docs.google.com/document/d/1YZ-lrH6nW871Vd9Z34Og_EqbX_kxxJi55UrSn4yL2Ak/edit?hl=en_US&pli=1#heading=h.zhq27f8o7rvi)