Delete keys in Redis
Note: Exercise caution when using any of these.
Delete all keys in the selected database:
1) The easy way
redis-cli -n <database number> flushdb
2) The fun way
redis-cli keys ‘*’ | awk ‘{print $1}’ | xargs redis-cli DEL
Delete all keys in all databases:
redis-cli flushall
Written by Abhinav Ajgaonkar
Related protips
2 Responses

Or you could run the more simple redis-cli flushall
; though it responds even with OK
when no keys were flushed. Attention: never run this on a productive system.
over 1 year ago
·

Aha! I had no idea flushall
and flushdb
existed. Thank you for that. I've updated the tip :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Redis
Authors
Related Tags
#redis
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#