Skip to content

Instantly share code, notes, and snippets.

@selmi-karim
Created June 4, 2020 17:06
Show Gist options
  • Save selmi-karim/18acc6f8ca4c89dcad9f0f46d847b219 to your computer and use it in GitHub Desktop.
Save selmi-karim/18acc6f8ca4c89dcad9f0f46d847b219 to your computer and use it in GitHub Desktop.
script to get, update and extend the TTL value of all the redis keys
## extend all the redis TTL keys
redis-cli keys '*' | xargs -n1 -I {} /bin/bash -c 'redis-cli expire {} $(redis-cli ttl {} | xargs -I{} echo {} + EXTEND_VALUE | bc)'
## update all the redis keys with new ttl value
redis-cli KEYS '*' | xargs -I{} redis-cli EXPIRE {} EXPIRE_VALUE
## get all the redis TTL keys
redis-cli KEYS '*' | xargs -I{} redis-cli TTL {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment