Target Cache gets checked twice for every cache hit [SPR-11592] #16216
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Jacques Stadler opened SPR-11592 and commented
Problem
Whenever you execute a cached method that has already been executed once, and therefore its result can be fetched from the cache, there will be 2 cache hits that happen for one execution of this method.
See e.g. this snippet from the referenced GitHub project:
I would expect that if I execute a cached method once, there should only be one cache hit, not two.
Solution
As I see it the problem lies in
org.springframework.cache.interceptor.CacheAspectSupport.execute(Invoker, CacheOperationContexts)
:I suppose the cached value should be fetched once, before calling the two methods (collectPutRequests, findCachedResult) above.
Affects: 4.0.2
Reference URL: https://github.com/stadler/poc-spring-cache
Issue Links:
@Cacheable
within@Caching
annotation doesn't work0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: