Skip to content

Instantly share code, notes, and snippets.

@bibigon812
Created July 13, 2018 08:34
Show Gist options
  • Save bibigon812/3ed16d4f19f0334d7b4754939e1489e4 to your computer and use it in GitHub Desktop.
Save bibigon812/3ed16d4f19f0334d7b4754939e1489e4 to your computer and use it in GitHub Desktop.
Drop all keys without a TTL in Redis
#!/bin/sh
redis-cli keys "*" | while read LINE ; do
TTL=`redis-cli ttl "$LINE"`
if [ $TTL -eq -1 ]; then
echo "$LINE" | redis-cli del
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment