rm
RM (remove key)
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Delete keys by pattern
Usage: rm key*. Deletes asynchronously.
Available since Ent 8.1.0.
The intent of this command: like 'ls' or 'll', you can delete keys by key pattern.
- rm * -> Deletes keys. There is an ll_max limit.
- rm key* -> Deletes keys that start with key.
- rm * string -> Deletes string keys.
- rm key* string -> Deletes string keys that start with key.
- Use with 'ls/ll': it is useful to check keys with ls/ll, then delete them.
You can use a glob-style pattern for the key.
- * : matches any characters: h*llo -> hllo, heeeello, etc
- ? : matches one character: h?llo -> hallo, hello, hxllo, etc
- [alphabet] : matches a character in the brackets: h[ae]llo -> hallo, hello
- [^e] : matches any character except those in the brackets:
h[^e]llo -> hallo, hbllo, ... but hello is excluded.
- [a-c] : matches a character range in the brackets: h[a-c]llo -> hallo, hbllo, hcllo
- \ : to use the special characters (*?[^]) as literals, prefix them with \.
Example
| Command> | rm key* |
| Result> | 1 |
| Command> | rm * string |
| Result> | 9 |
| Command> | rm mylist* list |
| Result> | 2 |
Syntax
RM key_pattern [type]
- type can be string/list/set/zset/hash/stream.
- Available since Enterprise version 8.0.0.
- Time complexity is O(N). N is the number of keys.
- Like KEYS, this command does a full scan of the DB and can affect server performance, so it is limited by the redis.conf ll-max parameter.
| Related commands | SCAN, DBSIZE |
| << LL | RM | SCAN >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
