| | |
| | | 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 |
| | | )); |
| | | } |
| | | |
| | | /** |