HOTKEYS GET

根据 HOTKEYS START 命令中选择的指标,返回前 K 个热键的列表。

语法

HOTKEYS GET

引入版本:8.6.0

复杂度摘要:O(K)

返回当前或最近热键跟踪会话的跟踪结果和元数据。

此命令返回有关热键跟踪会话的全面信息,包括:

  • 跟踪元数据(开始时间、持续时间、采样率等)
  • 性能统计(CPU时间、网络字节)
  • 按 HOTKEYS START 中指定的指标排序的前 K 个热键列表

针对非集群和集群 Redis 环境收集以下指标:

  • tracking-active(整数):如果跟踪处于活动状态,则为 1;如果停止,则为 0
  • sample-ratio(整数):跟踪时使用的采样率
  • selected-slots(数组):选择槽位和槽位范围的数组
  • all-commands-all-slots-us(整数):所有插槽上所有命令的 CPU 时间(以微秒为单位)
  • net-bytes-all-commands-all-slots(整数):所有插槽上所有命令的网络字节
  • collection-start-time-unix-ms(整数):跟踪开始时的 Unix 时间戳(以毫秒为单位)
  • collection-duration-ms(整数):跟踪持续时间(以毫秒为单位)
  • total-cpu-time-user-ms(整数):用户使用的 CPU 时间(以毫秒为单位)(仅当使用 HOTKEYS START 指定 CPU 指标时)
  • total-cpu-time-sys-ms(整数):使用的系统 CPU 时间(以毫秒为单位)(仅当使用 HOTKEYS START 指定 CPU 指标时)
  • total-net-bytes(整数):处理的总网络字节数(仅当使用 HOTKEYS START 指定 NET 指标时)
  • by-cpu-time-us(数组):按 CPU 时间(以微秒为单位)排序的关键时间对的 数组(仅当使用 HOTKEYS START 指定了 CPU 指标时)
  • by-net-bytes(数组):按网络字节排序的键字节对的 数组(仅当使用 HOTKEYS START 指定了 NET 指标时)

仅当 SLOTS 与 HOTKEYS START 一起使用时,才会在集群 Redis 环境中收集以下附加结果:

  • sampled-commands-selected-slots-us(整数):所选插槽中采样命令的 CPU 时间(以毫秒为单位)(仅当 SAMPLE 与 HOTKEYS START 一起使用时)
  • all-commands-selected-slots-us(整数):所选插槽中所有命令的 CPU 时间(以毫秒为单位)
  • net-bytes-sampled-commands-selected-slots(整数):所选插槽中采样命令的网络字节(仅当 SAMPLE 与 HOTKEYS START 一起使用时)
  • net-bytes-all-commands-selected-slots(整数):所选插槽上所有命令的网络字节

示例(指定了 NET 和 CPU 指标)

HOTKEYS GET
1)  1) "tracking-active"
    2) (integer) 0
    3) "sample-ratio"
    4) (integer) 1
    5) "selected-slots"
    6) 1) 1) (integer) 0
          2) (integer) 16383
    7) "all-commands-all-slots-us"
    8) (integer) 103
    9) "net-bytes-all-commands-all-slots"
   10) (integer) 2042
   11) "collection-start-time-unix-ms"
   12) (integer) 1770824933147
   13) "collection-duration-ms"
   14) (integer) 0
   15) "total-cpu-time-user-ms"
   16) (integer) 23
   17) "total-cpu-time-sys-ms"
   18) (integer) 7
   19) "total-net-bytes"
   20) (integer) 2038
   21) "by-cpu-time-us"
   22)  1) "hotkey_001_counter"
        2) (integer) 29
        3) "hotkey_001"
        4) (integer) 25
        5) "hotkey_001_hash"
        6) (integer) 11
        7) "hotkey_001_list"
        8) (integer) 9
        9) "hotkey_001_set"
       10) (integer) 9
   23) "by-net-bytes"
   24)  1) "hotkey_001"
        2) (integer) 446
        3) "hotkey_002"
        4) (integer) 328
        5) "hotkey_001_hash"
        6) (integer) 198
        7) "hotkey_001_set"
        8) (integer) 167
        9) "hotkey_001_counter"
       10) (integer) 116

Redis Software 与 Redis Cloud 兼容性

Redis
软件
Redis
Cloud
说明
✅ 标准
✅ 主动-主动
✅ 标准
✅ 主动-主动

返回值

RESP2

以下之一:

  • 数组回复(当跟踪数据可用时),包含具有交替字段名称和值的单个数组。
  • 空回复 当未启动跟踪或数据已重置时。

RESP3

以下之一:

  • 数组回复(当跟踪数据可用时),包含具有字段名称和值的单个 地图。
  • 空回复 当未启动跟踪或数据已重置时。

资料来源:Redis 官方 HOTKEYS GET 文档;中文内容参考 Redis 文档许可。