Redis 命令

命令的通用规则:返回值、帮助、文档约定。

Beginner
Key Points命令不区分大小写(习惯大写),可用 HELP 查帮助,返回值类型要心中有数。

通用规则

  • 命令名大小写不敏感,但约定全大写
  • 返回 (integer) 多为计数/影响行数
  • (nil) 表示空 / 不存在
  • (error) 开头是报错

查帮助

Shell
redis-cli HELP SET
redis-cli HELP @string     # 某一类命令的帮助
Output
  SET key value [expiration] [NX|XX]
  summary: Set the string value of a key.
Commands run atomically on one thread, so compound read-modify-write ops like INCR, SETNX are safe — the basis for distributed locks and counters.

Friends & Partners