@Cacheable javadoc states:

Note that Java8's Optional return types are automatically handled and its content is stored in the cache if present. (...)

This seems to suggest only present optionals are cached, that's not true. English isn't my first lang, so please forgive if I misunderstood, I guess "if present" may refer to the cache.

spring-context v5.3.1

Comment From: sbrannen

You're correct. The wording is slightly confusing. This applies to the Javadoc for @Cacheable as well as the documentation in the reference manual.

If an Optional return value is empty, null will be stored in the Cache just as if the return value itself were null.

Internally, this behavior is handled by org.springframework.util.ObjectUtils.unwrapOptional(Object).

Comment From: sbrannen

@mwojterski, thanks for opening your first issue for the Spring Framework.

We will update the documentation accordingly.