列出所有键

你可以通过执行 redis-cli 中的以下命令列出 Redis 数据库中的所有密钥:

KEYS *

KEYS 的参数是一个 glob 样式的模式匹配表达式。支持模式的示例包括:

h?llo matches hello, hallo and hxllo
h*llo matches hllo and heeeello
h[ae]llo matches hello and hallo, but not hillo
h[^e]llo matches hallo, hbllo, ... but not hello
h[a-b]llo matches hallo and hbllo

使用 KEYS *命令可能会对性能产生负面影响,因此不建议针对生产实例。使用 SCAN 操作搜索生产代码中的密钥。