增加清理缓存用户接口

This commit is contained in:
86182
2022-11-22 14:53:41 +08:00
parent 5875f4215d
commit 292e1cb650

View File

@@ -2,8 +2,11 @@ package com.xboe.module.tools.api;
import com.xboe.common.utils.StringUtil;
import com.xboe.constants.CacheName;
import com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,4 +29,23 @@ public class RedisCommandApi extends ApiBaseController {
Boolean delete = redisTemplate.delete(key);
return success(delete);
}
@GetMapping("/remove-usercache")
public JsonResponse<Boolean> removeUserCache(String id){
if(StringUtil.isBlank(id)){
return badRequest("参数异常");
}
String accountId="user::account:"+id;
String userId="user::user:"+id;
try {
redisTemplate.delete(accountId);
redisTemplate.delete(userId);
return success(true);
} catch (Exception e) {
return error("清楚失败",e.getMessage());
}
}
}