I wanted to know is there a way to use SpEL in order to filter out values like empty collections.
My cache currently filters out null values:
@Cacheable(value = "groupIdToGroupNames",unless = "#result == null")
public Map<Long, Collection<String>> findAllBySearchCustomerKey(final long groupId) {
return idToNameClient.findAllGroupMembersById(groupId);
}
I'm trying to find a way to filter out the groups that are of size 0 but not null. Is there a way of doing that by using params for @Cacheable?
Any help would be much appreciated.
Something like this
unless = "#result==null or #result.size()==0"
More about result and or.
unless = "#result==null or #result.isEmpty()"
works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With