Java 在@cacheexecute的键中使用非常量属性或字段
是否可以在Java 在@cacheexecute的键中使用非常量属性或字段,java,spring,spring-cache,Java,Spring,Spring Cache,是否可以在@cacheexecute注释的键中使用当前类的非常量字段或属性?例如: public class Feature { private int id; @Autowired private FeaturesClient featuresClient; @CacheEvict(value = CacheConfiguration.FEATURES, key = "T(java.lang.String).valueOf(
@cacheexecute
注释的键中使用当前类的非常量字段或属性?例如:
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);
}
}
对
:
#root.method
、#root.target
和#root.cache
分别用于引用方法、目标对象和受影响的缓存
@CacheEvict(key = "#userId + #root.target.id")