我在两个方法上有两个缓存。 brand
和brands
@CacheEvict(value ={ "brand" }, key = "#brand.brandId")
public Brand createOrUpdateBrand(final Brand brand){
}
@Cacheable("brands")
public Set<String> getAllBrandNames()
{
}
现在,我希望在调用brands
时逐出createOrUpdateBrand
。
我可以做类似以下的事情吗?
@CacheEvict(value ={ "brand" }, key = "#brand.brandId")
@CacheEvict("brands")
public Brand createOrUpdateBrand(final Brand brand){
}
OR
@Caching(evict = { @CacheEvict("brands"), @CacheEvict(value = "brand", key = "#brand.brandId") })