https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/cache/annotation/CachePut.html unless Unlike condition(), this expression is evaluated after the method has been called and can therefore refer to the result.

It is false. Condition is evaluated after the method has been called too and can refer to the result. I suppose it is the copy-paste from @Cacheable documentation.

Comment From: snicoll

What do you think is false exactly? @CachePut is very similar to @Cacheable and that condition is indeed invoked once the method has been invoked.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: MinaFayez9

Hi @snicoll

I faced a similar issue If you would accept my feedback the phrase "Unlike condition(), this expression is evaluated after the method has been called and can therefore refer to the result." makes you think that condition is going to be executed before the method body but what happens is that the method body is executed then the condition gets executed

so that makes us wonder what is the difference between condition and unless and what is the use-case for condition

Thanks

Comment From: snicoll

@mena149f Thanks for the feedback.

@streambuf apologizes there, you're right that both expressions are evaluated once the method body has been executed. This is by nature for @CachePut that states that the method is always executed. We may need to refine the javadoc there indeed.