skip to content
← Go back

Remove Redis keys by pattern

Simple command to do the job

Sometimes, you will need to remove all keys in Redis with a specific pattern, and flushdb is very dangerous and should be avoided on production.

So here is the command:

redis-cli KEYS "<replace_your_pattern_here>" | xargs redis-cli DEL

For example:

redis-cli KEYS "*ethereum*" | xargs redis-cli DEL

This command will remove all keys that have ethereum inside

Happy coding!

Recent Articles