*Redis ACL HELP 命令

ACL HELP 返回 ACL 子命令的帮助信息列表。


*语法

ACL HELP

*参数说明

参数 类型 必填 说明
该子命令不接受额外参数

*返回值

  • Array of Strings:逐行帮助文本

*时间复杂度

O(1)

*

*示例

*获取 ACL 帮助

> ACL HELP
 1) ACL <subcommand> [<arg> [value] [opt] ...]. Subcommands are:
 2) CAT
 3)     Return an array of ACL categories or commands within a category.
 4) DRYRUN
 5)     Returns whether the user can execute the given command without executing the command.
 6) GENPASS
 7)     Generate a pseudorandom secure password to use for ACL users.
 8) GETUSER
 9)     Return the complete configuration of a user.
10) HELP
11)     Return helpful text about the different subcommands.
12) LIST
13)     Return the current ACL rules in the Redis configuration file format.
14) LOAD
15)     Reload the ACL rules from the configured ACL file.
16) LOG
17)     Return the recent ACL security events as an array.
18) SAVE
19)     Save the current ACL rules to the configured ACL file.
20) SETUSER
21)     Create, update or delete a user.
22) USERS
23)     Return an array of usernames configured in the ACL system.
24) WHOAMI
25)     Return the username of the current connection.

*在脚本中解析帮助

> ACL HELP | head -3
1) ACL <subcommand> [<arg> [value] [opt] ...]. Subcommands are:
2) CAT
3)     Return an array of ACL categories or commands within a category.

*帮助信息的实际用途

> ACL HELP
...
> ACL SETUSER myuser +get +set ~* on >mypass
OK
> ACL DRYRUN myuser get mykey
OK

*常见错误

错误 原因 解决
ERR wrong number of arguments ACL HELP 后传入了额外参数 直接使用 ACL HELP,不加参数

*最佳实践

  • 新接触 ACL 时,这是学习所有子命令的最佳起点
  • 可以嵌入到管理脚本中,为用户展示可用操作
  • 帮助文本会随 Redis 版本更新而增加新子命令说明
  • 其他命令的 HELP 子命令通常也遵循相同模式,如 COMMAND HELP

*FAQ

Q1: ACL HELP 的输出格式是稳定的吗? A: 基本稳定,但 Redis 版本升级时可能增加新行(新子命令)。解析时应以行为单位,避免依赖固定索引。

Q2: 所有命令都有 HELP 子命令吗? A: 不是所有,但许多集群和管理命令有,如 CLUSTER HELPCOMMAND HELPSENTINEL HELP。建议尝试。

Q3: HELP 和官方文档有什么区别? A: HELP 是精简版,适合快速参考;官方文档更全面,包含示例和最佳实践。