I would like to delete entries that satisfy a condition(e.g : Delete entries endDate > now) using annotation provided by Spring over Ehcache, maybe with a SpEl expression.
Something like that :
@CacheEvict(value = Array("intensities"), condition = "samples.end > now")
def save(samples: Samples[Intensity]) = {
...
}
The more advanced eviction features are specific to the underlying Ehcache implementation, therefore they are not configurable through the basic abstractions offered by Spring. See sections
28.5.2and28.7in the Spring documentation.You can configure the eviction behavior of Ehcache in the
ehcache.xmlfile. Though not exactly the same what your code tries to achieve, thetimeToLiveSecondsattribute might be the one you are looking for. See the Ehcache documentation for more details.Update
On second thought, the following SpEL expression does exactly what you intended to do, without touching the Ehcache specific settings: