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.

Revisions

  1. selmi-karim created this gist Jun 4, 2020.
    9 changes: 9 additions & 0 deletions redis.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    ## 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 {}