我正在使用@cacheable注释来缓存函数的结果.我有3个不同的缓存,每个缓存的关键是当前登录用户的用户ID与方法中的参数连接.在某个事件中,我想要驱逐所有具有以该特定用户ID开头的密钥的缓存条目.例如 :
@Cacheable(value = "testCache1", key = "'abcdef'")
Run Code Online (Sandbox Code Playgroud)
我想缓存evict注释是这样的:
@CacheEvict(value = "getSimilarVendors", condition = "key.startsWith('abc')")
Run Code Online (Sandbox Code Playgroud)
但是当我尝试实现它时,它给了我一个错误:
Property or field 'key' cannot be found on object of type'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public?
Run Code Online (Sandbox Code Playgroud)
实现这个的正确方法是什么?