IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> SpringBoot服务获取Redis信息 -> 正文阅读

[Java知识库]SpringBoot服务获取Redis信息

利用ReatTemplate及方法获取Redis服务相关信息

@RestController
public class RedisCacheController {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

  
    @GetMapping("/monitor/cache")
    public Ret 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 Ret.success(result);
    }
}
{
    "msg": "操作成功",
    "code": 200,
    "data": {
        "commandStats": [
            {
                "name": "scan",
                "value": "23"
            },
            {
                "name": "set",
                "value": "9051"
            },
            {
                "name": "del",
                "value": "7796"
            },
            {
                "name": "select",
                "value": "284"
            },
            {
                "name": "info",
                "value": "1855"
            },
            {
                "name": "auth",
                "value": "22020"
            },
            {
                "name": "exec",
                "value": "3"
            },
            {
                "name": "ttl",
                "value": "40"
            },
            {
                "name": "get",
                "value": "751353"
            },
            {
                "name": "unlink",
                "value": "150"
            },
            {
                "name": "dbsize",
                "value": "916"
            },
            {
                "name": "type",
                "value": "40"
            },
            {
                "name": "setex",
                "value": "18895"
            },
            {
                "name": "multi",
                "value": "3"
            },
            {
                "name": "ping",
                "value": "84"
            },
            {
                "name": "keys",
                "value": "2170"
            }
        ],
        "info": {
            "aof_rewrite_scheduled": "0",
            "number_of_cached_scripts": "0",
            "mem_clients_slaves": "0",
            "keyspace_misses": "4501",
            "mem_allocator": "jemalloc-5.1.0",
            "multiplexing_api": "epoll",
            "aof_last_write_status": "ok",
            "used_memory_peak_perc": "62.82%",
            "run_id": "48e1f18af1cdd4bac634f4c046b220a33b2668d9",
            "uptime_in_seconds": "6982491",
            "maxmemory": "0",
            "active_defrag_hits": "0",
            "atomicvar_api": "atomic-builtin",
            "total_system_memory_human": "3.48G",
            "gcc_version": "4.8.5",
            "second_repl_offset": "-1",
            "arch_bits": "64",
            "master_repl_offset": "0",
            "instantaneous_output_kbps": "0.00",
            "total_commands_processed": "814682",
            "repl_backlog_size": "1048576",
            "sync_full": "0",
            "sync_partial_err": "0",
            "aof_last_cow_size": "0",
            "configured_hz": "10",
            "used_memory_startup": "791440",
            "mem_clients_normal": "49694",
            "used_cpu_user": "4095.380630",
            "aof_enabled": "0",
            "redis_mode": "standalone",
            "rdb_changes_since_last_save": "1",
            "used_memory_lua": "37888",
            "redis_build_id": "eac856754d7fb32",
            "connected_slaves": "0",
            "expired_keys": "11564",
            "used_memory": "1217696",
            "active_defrag_misses": "0",
            "active_defrag_key_misses": "0",
            "used_memory_rss": "8663040",
            "rdb_last_bgsave_status": "ok",
            "process_id": "1591",
            "rejected_connections": "0",
            "master_replid": "b08f981e483ff1503d0046e042545ba8f1203b12",
            "used_memory_rss_human": "8.26M",
            "used_memory_scripts": "0",
            "rdb_bgsave_in_progress": "0",
            "rdb_last_cow_size": "532480",
            "cluster_enabled": "0",
            "tcp_port": "6379",
            "os": "Linux 4.19.91-25.al7.x86_64 x86_64",
            "mem_replication_backlog": "0",
            "aof_current_rewrite_time_sec": "-1",
            "allocator_rss_ratio": "2.41",
            "used_memory_overhead": "862086",
            "repl_backlog_histlen": "0",
            "slave_expires_tracked_keys": "0",
            "used_cpu_sys": "2461.753645",
            "role": "master",
            "used_memory_dataset_perc": "83.43%",
            "expired_stale_perc": "0.00",
            "allocator_frag_ratio": "1.39",
            "client_recent_max_input_buffer": "2",
            "aof_last_bgrewrite_status": "ok",
            "used_memory_peak_human": "1.85M",
            "hz": "10",
            "used_memory_human": "1.16M",
            "maxmemory_policy": "noeviction",
            "rss_overhead_ratio": "2.09",
            "mem_fragmentation_ratio": "7.37",
            "rdb_last_bgsave_time_sec": "0",
            "allocator_allocated": "1234544",
            "used_memory_dataset": "355610",
            "blocked_clients": "0",
            "used_cpu_sys_children": "6.147227",
            "repl_backlog_active": "0",
            "used_cpu_user_children": "10.364512",
            "sync_partial_ok": "0",
            "aof_rewrite_in_progress": "0",
            "redis_git_sha1": "00000000",
            "rdb_current_bgsave_time_sec": "-1",
            "active_defrag_running": "0",
            "aof_last_rewrite_time_sec": "-1",
            "master_replid2": "0000000000000000000000000000000000000000",
            "config_file": "/www/server/redis/redis.conf",
            "lazyfree_pending_objects": "0",
            "used_memory_scripts_human": "0B",
            "loading": "0",
            "allocator_rss_bytes": "2420736",
            "pubsub_channels": "0",
            "db1": "keys=90,expires=0,avg_ttl=0",
            "used_memory_lua_human": "37.00K",
            "db0": "keys=204,expires=83,avg_ttl=38845722",
            "active_defrag_key_hits": "0",
            "allocator_frag_bytes": "481680",
            "migrate_cached_sockets": "0",
            "redis_git_dirty": "0",
            "total_system_memory": "3738521600",
            "mem_aof_buffer": "0",
            "rss_overhead_bytes": "4526080",
            "client_recent_max_output_buffer": "0",
            "connected_clients": "1",
            "mem_fragmentation_bytes": "7487576",
            "lru_clock": "7899428",
            "pubsub_patterns": "0",
            "expired_time_cap_reached_count": "0",
            "repl_backlog_first_byte_offset": "0",
            "total_net_output_bytes": "1319784901",
            "executable": "/www/server/redis/src/redis-server",
            "evicted_keys": "0",
            "total_connections_received": "13012",
            "allocator_active": "1716224",
            "mem_not_counted_for_evict": "0",
            "redis_version": "5.0.8",
            "total_net_input_bytes": "67132355",
            "latest_fork_usec": "239",
            "maxmemory_human": "0B",
            "used_memory_peak": "1938504",
            "allocator_resident": "4136960",
            "keyspace_hits": "746932",
            "uptime_in_days": "80",
            "instantaneous_input_kbps": "0.00",
            "instantaneous_ops_per_sec": "0",
            "rdb_last_save_time": "1652066505"
        },
        "dbSize": 204
    }
}

  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2022-05-10 11:43:27  更:2022-05-10 11:46:06 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 23:05:41-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码