Skip to content

Instantly share code, notes, and snippets.

@gr2m
Created March 15, 2012 20:47
Show Gist options
  • Save gr2m/2046802 to your computer and use it in GitHub Desktop.
Save gr2m/2046802 to your computer and use it in GitHub Desktop.
remove redis keys based on their expiration time
# remove all keys that will expire in less than 1 hour
redis-cli keys "*" | while read LINE ; do TTL=`redis-cli ttl $LINE`; if [ $TTL -le 3600 ]; then echo "Del $LINE"; RES=`redis-cli del $LINE`; fi; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment