mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 19:06:49 +08:00
增加清理缓存用户接口
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user