COMMAND

Syntax

  1. COMMAND

Time complexity: O(N) where N is the total number of Dragonfly commands

ACL categories: @slow, @connection

Return an array with details about every Dragonfly command.

The COMMAND command is introspective. Its reply describes all commands that the server can process. Clients can call it to obtain the server’s runtime capabilities during the handshake.

The reply it returns is an array with an element per command. Each element that describes a Dragonfly command is represented as an array by itself.

The command’s array consists of a fixed number of elements. The exact number of elements in the array depends on the server’s version.

  1. Name
  2. Arity
  3. Flags
  4. First key
  5. Last key
  6. Step

Name

This is the command’s name in lowercase.

Note: Command names are case-insensitive.

Arity

Arity is the number of arguments a command expects. It follows a simple pattern:

  • A positive integer means a fixed number of arguments.
  • A negative integer means a minimal number of arguments.

Command arity always includes the command’s name itself (and the subcommand when applicable).

Examples:

  • GET‘s arity is 2 since the command only accepts one argument and always has the format GET _key_.
  • MGET‘s arity is -2 since the command accepts at least one argument, but possibly multiple ones: MGET _key1_ [key2] [key3] ....

Flags

Command flags are an array. It can contain the following simple strings (status reply):

  • admin: the command is an administrative command.
  • blocking: the command may block the requesting client.
  • denyoom: the command is rejected if the server’s memory usage is too high (see the maxmemory configuration directive).
  • fast: the command operates in constant or log(N) time. This flag is used for monitoring latency with the LATENCY command.
  • loading: the command is allowed while the database is loading.
  • noscript: the command can’t be called from scripts.
  • readonly: the command doesn’t modify data.
  • write: the command may modify data.

First key

The position of the command’s first key name argument. For most commands, the first key’s position is 1. Position 0 is always the command name itself.

Last key

The position of the command’s last key name argument. Commands usually accept one, two or multiple number of keys.

Commands that accept a single key have both first key and last key set to 1.

Commands that accept two key name arguments, e.g. BRPOPLPUSH, SMOVE and RENAME, have this value set to the position of their second key.

Multi-key commands that accept an arbitrary number of keys, such as MSET, use the value -1.

Step

The step, or increment, between the first key and the position of the next key.

Consider the following two examples:

  1. 1) 1) "mset"
  2. 2) (integer) -3
  3. 3) 1) write
  4. 2) denyoom
  5. 4) (integer) 1
  6. 5) (integer) -1
  7. 6) (integer) 2
  8. ...
  1. 1) 1) "mget"
  2. 2) (integer) -2
  3. 3) 1) readonly
  4. 2) fast
  5. 4) (integer) 1
  6. 5) (integer) -1
  7. 6) (integer) 1
  8. ...

The step count allows us to find keys’ positions. For example MSET: Its syntax is MSET _key1_ _val1_ [key2] [val2] [key3] [val3]..., so the keys are at every other position (step value of 2). Unlike MGET, which uses a step value of 1.

Return

Array reply: a nested list of command details.

The order of commands in the array is random.

Examples

The following is COMMAND‘s output for the GET command:

  1. 1) 1) "get"
  2. 2) (integer) 2
  3. 3) 1) readonly
  4. 2) fast
  5. 4) (integer) 1
  6. 5) (integer) 1
  7. 6) (integer) 1
  8. 7) 1) @read
  9. 2) @string
  10. 3) @fast
  11. 8) (empty array)
  12. 9) 1) 1) "flags"
  13. 2) 1) read
  14. 3) "begin_search"
  15. 4) 1) "type"
  16. 2) "index"
  17. 3) "spec"
  18. 4) 1) "index"
  19. 2) (integer) 1
  20. 5) "find_keys"
  21. 6) 1) "type"
  22. 2) "range"
  23. 3) "spec"
  24. 4) 1) "lastkey"
  25. 2) (integer) 0
  26. 3) "keystep"
  27. 4) (integer) 1
  28. 5) "limit"
  29. 6) (integer) 0
  30. 10) (empty array)
  31. ...