-
-
Save f9n/1240c5515079adf91b0427cfd60c5868 to your computer and use it in GitHub Desktop.
Delete all keys without a TTL in Redis
This file contains 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
#!/bin/sh | |
LIMIT=$1 | |
redis-cli keys "*" | head -n $LIMIT > keys.txt | |
cat keys.txt | xargs -n 1 -L 1 redis-cli ttl > ttl.txt | |
paste -d " " keys.txt ttl.txt | grep .*-1$ | cut -d " " -f 1 | xargs redis-cli del |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment