08-02-2023, 07:07 AM
Is there a way to specify that if the method returns null value, then don't cache the result in @Cacheable annotation for a method like this?
@Cacheable(value="defaultCache", key="#pk")
public Person findPerson(int pk) {
return getSession.getPerson(pk);
}
Update:
here is the JIRA issue submitted regarding caching null value last November, which hasn't resolved yet:
[\[#SPR-8871\] @Cachable condition should allow referencing return value - Spring Projects Issue Tracker][1]
[1]:
@Cacheable(value="defaultCache", key="#pk")
public Person findPerson(int pk) {
return getSession.getPerson(pk);
}
Update:
here is the JIRA issue submitted regarding caching null value last November, which hasn't resolved yet:
[\[#SPR-8871\] @Cachable condition should allow referencing return value - Spring Projects Issue Tracker][1]
[1]:
[To see links please register here]