Last active
February 15, 2016 20:27
-
-
Save Gowiem/d4916fca2503951350fc to your computer and use it in GitHub Desktop.
Clean up Redis by deleting keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pull all keys matching wildcard from your Replica so you're not using KEYS on your primary. | |
$ redis-cli -h $ELASTI_CACHE_REPLICA_URL KEYS "*WILDCARD*" > keys.txt | |
# For each key that has been collected, prepend the DEL command. | |
$ sed ':a;N;$!ba;s/\n/\n DEL /g' keys.txt > del_keys.txt | |
# Feed the new DEL commands into your primary. Run via nohup + background as deleting millions of keys can take hours. | |
$ nohup redis-cli -h $ELASTI_CACHE_URL < del_keys.txt & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment