I wanted to remove thousands of keys from the template, after some searches I found the following items:
- if you have more than 1dB on Redis, you must define the database using
-n [number] - if you have several keys, use
del but if there are thousands or millions of keys, it is better to use unlink because unlink is non-blocking and del is blocking, for more information visit this page unlink vs del - also
keys as del and locks
so I used this code to remove keys by pattern:
redis-cli -n 2 --scan --pattern '[your pattern]' | xargs redis-cli -n 2 unlink
source share