-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Mario Philipps opened SPR-9304 and commented
In many cases, @Cacheable annotated methods will read a given resource (such as a database table), and @CacheEvict annotated methods will update this resource. Unfortunately, there is a race condition that can lead to outdated cache contents. Consider the following schedule, with thread A reading the resource, thread B updating it:
A: entering @Cacheable
A: reading resource in state 1
B: entering @CacheEvict
B: updating resource to state 2
B: leaving @CacheEvict, invalidating the cache
A: leaving @Cacheable, writing state 1 to the cache
Now the resource is in state 2, the cache in state 1, but marked valid.
It would be great if there was some (optional) synchronization between the two cache annotations, that prevents such a race condition, if possible even in multi-node configurations.
Affects: 3.1.1
Issue Links:
- Provide means to configure multithreaded access for cache abstraction [SPR-9254] #13892 Provide means to configure multithreaded access for cache abstraction
- @CacheRefresh to request a refresh of a stale object in the cache [SPR-9592] #14226
@CacheRefreshto request a refresh of a stale object in the cache - Support of ehcache's BlockingCache [SPR-11540] #16165 Support of ehcache's BlockingCache
5 votes, 14 watchers