I have a weird case where my @CacheEvict is not working. Code looks like this:
@Caching(evict = {
@CacheEvict(value = CacheConsts.C_CACHE1, keyGenerator = CacheConsts.KG_CACHE1, condition="#someModel != null && #someModel.getSomeProperty() != null"),
@CacheEvict(value = CacheConsts.C_CACHE2, keyGenerator = CacheConsts.KG_CACHE2, condition="#someModel != null && #someModel.getSomeProperty() != null"),
@CacheEvict(value = CacheConsts.C_CACHE3, keyGenerator = CacheConsts.KG_CACHE3, condition="#someModel != null && #someModel.getSomeProperty() != null")
})
public boolean addModel(ModelDTO someModel, String tenant);
However, it works when I remove the condition!!! Even though all data I test with is non-null.
Ex: when I remove this: "#someModel != null && #someModel.getSomeProperty() != null", it works.
I'm testing with a ModelDTO that is not null and the "someProperty" is not null either.
It seems to me that the condition would pass and it would evict.. but that is not what's happening.
Any ideas?
Is my Spel properly formed?
Why would my cache not evict here?
Does this have something to do with the @Caching annotation or some behavior of CacheEvict's condition that I'm unaware of?
Thanks for any help or ideas folks.