update 优化 pr201 代码逻辑

This commit is contained in:
疯狂的狮子li
2022-07-14 21:26:51 +08:00
parent ca301891db
commit 8a930bd7d5
3 changed files with 65 additions and 46 deletions

View File

@ -1,12 +1,12 @@
package com.ruoyi.web.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.redis.RedisUtils;
import com.ruoyi.oss.constant.OssConstant;
import com.ruoyi.system.domain.SysCache;
import lombok.RequiredArgsConstructor;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
@ -38,6 +38,7 @@ public class CacheController {
CACHES.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
CACHES.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
CACHES.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
CACHES.add(new SysCache(OssConstant.SYS_OSS_KEY, "OSS配置"));
}
/**
@ -86,8 +87,7 @@ public class CacheController {
@SaCheckPermission("monitor:cache:list")
@GetMapping("/getKeys/{cacheName}")
public R<Collection<String>> getCacheKeys(@PathVariable String cacheName) {
Iterable<String> iterable = RedisUtils.getClient().getKeys().getKeysByPattern(cacheName + "*");
Collection<String> cacheKyes = CollUtil.toCollection(iterable);
Collection<String> cacheKyes = RedisUtils.keys(cacheName + "*");
return R.ok(cacheKyes);
}
@ -113,7 +113,7 @@ public class CacheController {
@SaCheckPermission("monitor:cache:list")
@DeleteMapping("/clearCacheName/{cacheName}")
public R<Void> clearCacheName(@PathVariable String cacheName) {
RedisUtils.getClient().getKeys().deleteByPattern(cacheName + "*");
RedisUtils.deleteKeys(cacheName + "*");
return R.ok();
}
@ -135,7 +135,7 @@ public class CacheController {
@SaCheckPermission("monitor:cache:list")
@DeleteMapping("/clearCacheAll")
public R<Void> clearCacheAll() {
RedisUtils.getClient().getKeys().deleteByPattern("*");
RedisUtils.deleteKeys("*");
return R.ok();
}