首页>代码>基于 SpringBoot + vue 企业信息管理系统>/liawan-vue/liawan-admin/src/main/java/com/javapub/liawan/admin/controller/monitor/CacheController.java
package com.javapub.liawan.admin.controller.monitor; import com.javapub.liawan.common.core.domain.AjaxResult; import com.javapub.liawan.common.utils.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.*; /** * 缓存监控 * * @author ruoyi */ @RestController @RequestMapping("/monitor/cache") public class CacheController { @Autowired private RedisTemplate<String, String> redisTemplate; @PreAuthorize("@ss.hasPermi('monitor:cache:list')") @GetMapping() public AjaxResult getInfo() throws Exception { Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); Map<String, Object> result = new HashMap<>(3); result.put("info", info); result.put("dbSize", dbSize); List<Map<String, String>> pieList = new ArrayList<>(); commandStats.stringPropertyNames().forEach(key -> { Map<String, String> data = new HashMap<>(2); String property = commandStats.getProperty(key); data.put("name", StringUtils.removeStart(key, "cmdstat_")); data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); pieList.add(data); }); result.put("commandStats", pieList); return AjaxResult.success(result); } }

qinzhifang LV1
3月15日
叶云浩 LV2
3月1日
zhangtian1997 LV10
2月5日
依旧原地徘徊 LV12
1月16日
ooosehun LV1
2024年12月18日
zolscy LV24
2024年11月27日
yangchengshuai LV15
2024年10月29日
mlml123 LV6
2024年8月20日
TY0165 LV20
2024年6月17日
vacalono LV1
2024年5月16日

zdh3907 LV15
昨天
Solowen
4月16日
暂无贡献等级
feng0519
3月25日
暂无贡献等级
qinzhifang LV1
3月15日
叶云浩 LV2
3月1日
微信网友_7044194812350464 LV8
2月28日
微信网友_7371218154688512 LV4
2月5日
zhangtian1997 LV10
2月5日
f22m1a2b2 LV17
1月23日
2602275348 LV12
2024年12月26日