At present, @Cacheable, @CacheEvict and @CachePut evaluate their keys after condition but before unless. I think the keys should be evaluated after all the cache condition which contains the condition and unless.

I change the code, add the corresponding test cases and fix the JavaDoc for @Cacheable, @CacheEvict and @CachePut.

Fixes #22294.

Comment From: capatcapworld

When will this fix be merged in to master ? We have this problem in our code.

Comment From: lgxbslgx

I merged the main branch and solved the conflicts just now.

Comment From: snicoll

It took me a bit to understand why the evaluation of cacheable was moved as it felt unrelated but evaluating the unless expression earlier means that we need the result for cacheable as well.

Comment From: snicoll

@lgxbslgx thank you for making your first contribution to Spring Framework.