https://github.com/spring-projects/spring-data-redis/issues/3089#issue-2782880207 Can we not handle the cache when return is null not throw error to main thread?

Comment From: quaff

You can return Optional.empty() instead of null if #34258 is accepted.

Comment From: wangsp188

@quaff Thanks

why not is support return null? By the way, please.

Comment From: quaff

why not is support return null? By the way, please.

It's bad to change the method contract.

Comment From: snicoll

https://github.com/spring-projects/spring-data-redis/issues/3089#issuecomment-2586454250:

But we can't predict whether the method's entry is reasonable or not. ,

You should. The cache key must be predictable and provide a proper contract. If you decide to provide your own algorithm you are responsible for it to be a valid key for whatever you intend to cache.