概述
在进行redis的操作的时候,有时候需要对多个键一起操作。那么注解如何可以进行批量的操作呢,这个地方就使用到了这个@Cacheing。
@Caching(
evict = {
@CacheEvict(value = "default",
key = "T(org.loulan.dawn.application.common.pojo.config.redis.RedisArea).USER_DAWN_RESOURCE + #userId",
unless = "#result == true "),
@CacheEvict(value = "default",
key = "T(org.loulan.dawn.application.common.pojo.config.redis.RedisArea).USER_VUE_ELEMENT_RESOURCE + #userId",
unless = "#result == true "),
@CacheEvict(value = "default",
key = "T(org.loulan.dawn.application.common.pojo.config.redis.RedisArea).USER_VUE_MENU_RESOURCE + #userId",
unless = "#result == true ")
}
)
public Boolean insertUserRole(List<String> roleIds, String userId){}
也可以在里面添加put和cacheable
@Caching(
put = {
@CachePut(value = "default",
key = "T(org.loulan.dawn.application.common.pojo.config.redis.RedisArea).USER_INFO + #userId",
unless = "#result == null")
},
evict = {
@CacheEvict(value = "default",
key = "T(org.loulan.dawn.application.common.pojo.config.redis.RedisArea).USER_DAWN_RESOURCE + #userId",
unless = "#result == null ")
}
)
public User insertUserRole(List<String> roleIds, String userId){}
注 注解得使用