疯狂的狮子Li
2023-01-31 771a1045ee3ef382d02b08afb620ef0b34d9d13a
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/CacheController.java
@@ -6,6 +6,7 @@
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JsonUtils;
import com.ruoyi.common.core.utils.StreamUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.redis.utils.CacheUtils;
import com.ruoyi.common.redis.utils.RedisUtils;
@@ -16,7 +17,6 @@
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 缓存监控
@@ -51,13 +51,7 @@
    @GetMapping()
    public R<Map<String, Object>> getInfo() throws Exception {
        RedisConnection connection = connectionFactory.getConnection();
        Properties info = connection.commands().info();
        Properties commandStats = connection.commands().info("commandstats");
        Long dbSize = connection.commands().dbSize();
        Map<String, Object> result = new HashMap<>(3);
        result.put("info", info);
        result.put("dbSize", dbSize);
        List<Map<String, String>> pieList = new ArrayList<>();
        if (commandStats != null) {
@@ -69,8 +63,11 @@
                pieList.add(data);
            });
        }
        result.put("commandStats", pieList);
        return R.ok(result);
        return R.ok(Map.of(
                "info", connection.commands().info(),
                "dbSize", connection.commands().dbSize(),
                "commandStats", pieList
        ));
    }
    /**
@@ -94,7 +91,7 @@
        if (isCacheNames(cacheName)) {
            Set<Object> keys = CacheUtils.keys(cacheName);
            if (CollUtil.isNotEmpty(keys)) {
                cacheKeys = keys.stream().map(Object::toString).toList();
                cacheKeys = StreamUtils.toList(keys, Object::toString);
            }
        } else {
            cacheKeys = RedisUtils.keys(cacheName + "*");