首页>代码>基于 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); } }
最近下载更多
dapeng0011 LV13
3月2日
微信网友_6873044563791872 LV1
2月19日
肸乯 LV8
1月31日
xiexiaoming05 LV14
1月26日
siximu912 LV10
1月23日
zhangwuxuan
2023年12月31日
暂无贡献等级
Jingbo Jia LV2
2023年12月9日
1515465193 LV9
2023年11月30日
wuying8208 LV15
2023年11月28日
唐唐丶 LV33
2023年11月20日
最近浏览更多
hmf1989
2小时前
暂无贡献等级
860421 LV3
4月18日
可是不知道么 LV23
4月16日
微信网友_6935352109010944 LV2
4月5日
玖零定制问题修复 LV34
4月4日
微信网友_6927932988952576 LV12
3月30日
赵文俊
3月16日
暂无贡献等级
ChenZheMeng LV3
3月9日
2771547747
3月6日
暂无贡献等级
小王wang LV10
2月29日