Why is this an issue?

@Cacheable annotation is used to store the result of a method and avoid executing it for the same inputs. @CachePut instead is used to force the execution of a method and store the result in the cache. Annotating a method with both will produce unreliable behavior, except for specific corner-cases when their condition() or unless() expressions are mutually exclusive. Hence this pattern is strongly discouraged and an issue will be raised on such cases.

How to fix it

Code examples

Noncompliant code example

@Cacheable
@CachePut
void getBook(String isbn){ // Non compliant, methods annotated with both @Cacheable and @CachePut will not behave as intended
    ...
}

Compliant solution

@Cacheable
void getBook(String isbn){
    ...
}

Resources

Documentation