Spring Boot 更新、清除多个缓存

it2025-01-15  4

使用 注解 @Caching ,源码如下

@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface Caching { Cacheable[] cacheable() default {}; CachePut[] put() default {}; CacheEvict[] evict() default {}; } //更新多个 @Caching(put = { @CachePut(value = "user",key = "#key"), @CachePut(value = "user",key = "#key2") }) //删除多个 @Caching(evict = { @CacheEvict(value = "user",key = "#key"), @CacheEvict(value = "user",key = "#key2") })

 

最新回复(0)