本文内容为 http://redis.io/commands/command-getkeys 的翻译、注解、例子扩充及其它修改。感谢 Redis 作者 Antirez 为开源社区作出的贡献,本文保证最新、最准、最全以表示对其的敬意。欢迎留言纠错、提示更新或支持。
OMMAND GETKEYS

返回一条完整的 Redis 命令中,所有键组成的数组响应(Array reply)

Returns Array reply of keys from a full Redis command.

COMMAND GETKEYS is a helper command to let you find the keys from a full Redis command.

由命令 COMMAND 可知,部分命令的键的位置是不固定(Movable)的,即意味着需要一次性解析整条命令才能发现存储(storage)或回执(Retrieval)键。你可以使用当前命令以通过 Redis 自已的命令解释方式,直接获得键的位置。

COMMAND shows some commands as having movablekeys meaning the entire command must be parsed to discover storage or retrieval keys. You can use COMMAND GETKEYS to discover key positions directly from how Redis parses the commands.
  • 以列表形式返回命令中的所有键。

    Array reply: list of keys from your command.
  • redis> COMMANDGETKEYS MSET a b c d e f
    1) "a"
    2) "c"
    3) "e"
    redis> COMMANDGETKEYS EVAL "not consulted" 3 key1 key2 key3 arg1 arg2 arg3 argN
    1) "key1"
    2) "key2"
    3) "key3"
    redis> COMMANDGETKEYS SORT mylist ALPHA STORE outlist
    1) "mylist"
    redis>
  • 版本支持

    2.8.13+

    时间复杂度(Time complexity)

    O(N)N 为命令中参数的数量。

    O(N) where N is the number of arugments to the command