| | |
| | | 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; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 缓存监控 |
| | |
| | | @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) { |
| | |
| | | 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 |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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 + "*"); |