rm_subquery
RMS (subquery)
Subquery feature
You can delete keys by using a subquery in the key part.
Commands that can be used as a subquery are GET, MGET, LPOP, RPOP, LRANGE,
SMEMBERS, SUNION, SINTER, SDIFF, ZRANGE, ZREVRANGE,
HGET, HMGET, HKEYS, HVALS, HGETALL, KEYS, LS.
Example
| Command> | set mykey myvalue |
| Result> | OK |
| Command> | set key mykey |
| Result> | OK |
| Command> | rms (get key) |
| Result> | 1 |
You can delete multiple keys.
Example
| Command> | lpush mylist mykey1 mykey2 mykey3 |
| Result> | 3 |
| Command> | rms (lrange mylist 0 -1) |
| Result> | 3 |
You can use the ls command.
Example
| Command> | rms (ls user*) delete keys starting with user |
| Result> | 10 |
| Command> | rms (ls * string) delete all keys whose data type is string |
| Result> | 20 |
| Command> | rms (ls * count 10) delete 10 arbitrary keys |
| Result> | 10 |
You can use multiple subqueries.
Example
| Command> | rms (lrange mylist 0 -1) (sunion myset1 myset2) mykey10 |
| Result> | 10 |
Syntax
RMS (subquery)
- Available since Enterprise version 7.2.5.
- Time complexity is O(N). N is the number of keys to delete.