I am using @Cacheable annotation to cache the results of my method. For performance reason I want to cache both null and non-null values returned from method.
But problem here is Spring is caching non-null values but not caching null for some reason.
Here is my code:
@Cacheable(
cacheManager = "promoCacheManager",
value = "promos:campaign",
key = "'promos:campaign:'.concat(#currencyId)"
)
public PromosDto getPromosByCurrency(Integer currencyId) {
...
I have tried every thing. Even I set
unless = "#result != null || #result == null"
But that didn't help as well. Any pointer on this?