疯狂的狮子li
2022-07-27 26b0dc336ac804d9b115bcb9606632cf0a07bd9f
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
@@ -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 @@
        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,9 +87,8 @@
    @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);
        return R.ok(cacheKyes);
        Collection<String> cacheKeys = RedisUtils.keys(cacheName + "*");
        return R.ok(cacheKeys);
    }
    /**
@@ -113,7 +113,7 @@
    @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 @@
    @SaCheckPermission("monitor:cache:list")
    @DeleteMapping("/clearCacheAll")
    public R<Void> clearCacheAll() {
        RedisUtils.getClient().getKeys().deleteByPattern("*");
        RedisUtils.deleteKeys("*");
        return R.ok();
    }