Redis: How to delete keys matching a pattern
Posted by Stanislav Furman on April 10, 2014Sometimes you might want to purge a set of similar Redis keys in one shot. So far, standard Redis "DEL" command does not allow to remove keys using patterns. However, there is a trick to do this action. Execute the following command in bash:
redis-cli -h [host] -p [port] KEYS "prefix:*" | xargs redis-cli DEL
Seems clear? Wait a minute! What if you use multiple databases (keyspaces) and need to remove keys from a database different from default (0) one? No problem there! Here is the solution:
Continue reading