是否可以在@CacheEvict
注解的键中使用当前类的非常量字段或属性?例如:
public class Feature {
private int id;
@Autowired
private FeaturesClient featuresClient;
@CacheEvict(value = CacheConfiguration.FEATURES, key =
"T(java.lang.String).valueOf(#userId).concat(T(java.lang.String)" +
".valueOf( **#id** ))")
public boolean isFeatureAvailable(long userId) {
return featuresClient.isFeatureAvailable(userId, id);
}
}
最佳答案
是的。
@CacheEvict(key = "#userId + #root.target.id")
#root.method
,#root.target
, and#root.caches
for references to the method, target object, and affected cache(s) respectively.
关于java - 在 @CacheEvict 的键中使用非常量属性或字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45799079/