Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/command-reference/server-management/command-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ import PageTitle from '@site/src/components/PageTitle';

**ACL categories:** @slow, @connection

Returns [Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#integers) of number of total commands in this Dragonfly server.
Returns the number of total commands in this Dragonfly server.

## Return

[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#integers): number of commands returned by `COMMAND`
[Integer reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#integers): number of commands returned by `COMMAND`.

## Examples

```shell
dragonfly> COMMAND COUNT
(integer) 240
(integer) 283
```

## Tips

- Counts only non-hidden commands (commands marked with the `HIDDEN` flag are excluded from `COMMAND`).
- Equivalent to the number of elements returned by `COMMAND` without subcommands.

## See also

[`COMMAND`](./command.md) | [`COMMAND INFO`](./command-info.md)
45 changes: 45 additions & 0 deletions docs/command-reference/server-management/command-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
description: Learn how to use Redis COMMAND HELP to display usage information for COMMAND subcommands.
---

import PageTitle from '@site/src/components/PageTitle';

# COMMAND HELP

<PageTitle title="Redis COMMAND HELP Command (Documentation) | Dragonfly" />

## Syntax

COMMAND HELP

**Time complexity:** O(1)

**ACL categories:** @slow, @connection

Return usage information for the supported `COMMAND` subcommands in this Dragonfly server.

## Return

[Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#arrays): a list of human-readable help lines.

## Examples

```shell
dragonfly> COMMAND HELP
1) (no subcommand)
2) Return details about all commands.
3) INFO command-name
4) Return details about specified command.
5) COUNT
6) Return the total number of commands in this server.
```

## Tips

- The help lines reflect only subcommands currently supported by Dragonfly.
- For instance, `COMMAND DOCS` is not implemented at the moment and returns an error when called.


## See also

[`COMMAND`](./command.md) | [`COMMAND INFO`](./command-info.md) | [`COMMAND COUNT`](./command-count.md)
8 changes: 7 additions & 1 deletion docs/command-reference/server-management/command-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ dragonfly> COMMAND INFO UNKNOWN_COMMAND
(nil)
```

## Notes
## Tips

- Command names are case-insensitive.
- The output schema is stable but may include more fields in future versions.
- See [`COMMAND`](./command.md) for the general reply format.


## See also

[`COMMAND`](./command.md) | [`COMMAND COUNT`](./command-count.md) | [`ACL CAT`](../acl/cat.md)
183 changes: 109 additions & 74 deletions docs/command-reference/server-management/command.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,121 +22,156 @@ 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.
## Subcommands

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.
- [`COMMAND HELP`](./command-help.md): Show usage information for supported subcommands.
- [`COMMAND COUNT`](./command-count.md): Return the total number of commands.
- [`COMMAND INFO`](./command-info.md): Return details about a specific command.

Unsupported in Dragonfly:

- `COMMAND DOCS`: Not implemented. The server returns an error.

---

## Return

[Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#arrays): a nested list of command details.
The order of commands in the array is random.

The reply is an array with **an element per command**.
Each element that describes a Dragonfly command is represented as a fixed-length array by itself.
The exact number of elements in the command's array depends on the server's version.

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

## Name
### Name

This is the command's name in lowercase.
This is the command's name. Note that command names are case-insensitive.

**Note:**
Command names are case-insensitive.

## Arity
### 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).
- A positive integer means a fixed number of arguments.
- A negative integer means a minimal number of arguments.

Examples:
Command arity **always includes** the command's name itself (and the subcommand when applicable).
For example:

* `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] ...`.
- `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 key [key ...]`.

## Flags
### Flags

Command flags are an array. It can contain the following simple strings (status reply):
Command flags are returned as 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](https://redis.io/docs/latest/develop/interact/programmability/eval-intro/).
* **readonly:** the command doesn't modify data.
* **write:** the command may modify data.
- `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`](../../managing-dragonfly/flags#--maxmemory) configuration directive).
- `fast`: The command operates in constant or log(N) time.
- `loading`: The command is allowed while the database is loading.
- `noscript`: The command can't be called from [scripts](https://redis.io/docs/latest/develop/interact/programmability/eval-intro/).
- `readonly`: The command doesn't modify data.
- `write`: The command may modify data.

## First key
### 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.
For most commands, the first key's position is `1`.
Position `0` is always the command name itself.

## Last key
### 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 usually accept one, two, or multiple number of keys.
- Commands that accept a single key have both the **first key** and the **last key** set to `1`.
- Commands that accept two key name arguments (e.g., `SMOVE`) have this value set to the position of their second key.
- Multi-key commands that accept an arbitrary number of keys (e.g., `MSET`) have the value `-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.
### Step

The step, or increment, between the first key and the position of the next key.
Consider the following two examples:

```
1) 1) "mset"
2) (integer) -3
3) 1) write
2) denyoom
4) (integer) 1
5) (integer) -1
6) (integer) 2
...
```bash
dragonfly> COMMAND
# ...
1) MSET
2) (integer) -3
3) 1) write
2) denyoom
3) interleaved-keys
4) custom-journal
4) (integer) 1
5) (integer) -1
6) (integer) 2
7) 1) @WRITE
2) @STRING
3) @SLOW
# ...
```

```
1) 1) "mget"
2) (integer) -2
3) 1) readonly
2) fast
4) (integer) 1
5) (integer) -1
6) (integer) 1
...
```bash
dragonfly> COMMAND
# ...
1) MGET
2) (integer) -2
3) 1) readonly
2) fast
3) idempotent
4) (integer) 1
5) (integer) -1
6) (integer) 1
7) 1) @READ
2) @STRING
3) @FAST
# ...
```

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_.
- For example, the `MSET` command has a syntax of `MSET key1 val1 [key2] [val2] [key3] [val3]...`,
so the keys are at every other position, which has a step value of `2`.
- For the `MGET` command with a syntax of `MGET key1 [key2] [key3]...`, it uses a step value of `1`.

## Return
### ACL categories

[Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec/#arrays): a nested list of command details.
Command ACL categories are returned as an array.
For instance, the `MSET` command shown above is categorized as `@write`, `@string`, and `@slow` from the ACL perspective.
Learn more about [ACL rules](../acl/setuser.md) to control your data store access.

The order of commands in the array is random.
---

## Examples

The following is `COMMAND`'s output for the `GET` command:

```bash
dragonfly> COMMAND
# ...
1) GET # Name
2) (integer) 2 # Arity
3) 1) readonly # Flags (array)
2) fast
4) (integer) 1 # First key
5) (integer) 1 # Last key
6) (integer) 1 # Step
7) 1) @READ # ACL categories (array)
2) @STRING
3) @FAST
# ...
```
1) 1) "get"
2) (integer) 2
3) 1) readonly
2) fast
4) (integer) 1
5) (integer) 1
6) (integer) 1
...
```

## Tips

- Command names are case-insensitive.
- Hidden commands (with the `HIDDEN` flag) are not returned.
- Use [`COMMAND HELP`](./command-help.md) to discover supported subcommands.