Persist all keys in redis
Intro
Being a beginner in redis I was surprised that bulk commands are not that easy and even Stackoverflow baulks at the question for mass persistence.
So it's good to have the script at https://rdbtools.com/blog/redis-set-expiry-multiple-keys-regex-using-scan/ handy. Just download the raw file with
wget https://gist.githubusercontent.com/sripathikrishnan/ebe0cbd6dbb17f2936b9c3826b02c57f/raw/8614ccb112b10f29578bf44f57d5092e44f32931/bulk_expiry.sh
Be very careful to edit this snippet only with an editor that does no formatting (I use emacs). Then adjust the pattern for the scan command and replace
"expire __key__ 1000" with "persist __key__"
, rename to bulk_persist.sh or sth. and make the file executable with
chmod +x bulk_persist.ch
Hope it helps.
Posted: 11 February 2022