Redis: Redis Command Reference

Redis Command Reference

1. General Commands

▶ Example

Basic connection and operations:

BASH
127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET mykey "Hello"
OK
127.0.0.1:6379> GET mykey
"Hello"
127.0.0.1:6379> DBSIZE
(integer) 1

2. Key Commands

Command Description Syntax
SET Set key-value `SET key value [EX seconds] [PX ms] [NX
GET Get key value GET key
DEL Delete key DEL key [key ...]
EXISTS Check key exists EXISTS key [key ...]
EXPIRE Set expiration EXPIRE key seconds
TTL View expiration TTL key
KEYS Find keys KEYS pattern
SCAN Iterate keys SCAN cursor [MATCH pattern] [COUNT count]

❓ FAQ

Q How to view detailed usage of a command?
A Use HELP command_name in redis-cli, e.g. HELP SET, to display syntax, description, and version info.
Q Are Redis commands case-sensitive?
A Redis commands are case-insensitive; SET and set are equivalent. However, key names and values are case-sensitive.
Q How to view all supported Redis commands?
A Use the COMMAND command to list all commands, or COMMAND INFO command_name for specific command details.

📖 Summary


📝 Exercises

  1. Command lookup: Use HELP to view detailed descriptions of SET, GET, and HSET commands
  2. Command classification: Organize Redis commands by type into notes
  3. Command practice: Execute at least 3 different commands for each data type
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏