Using Open Source Dump Analysis
redis-rdb-tools can parse your rdb backup files and generate a csv. One of the several columns is the expiry of the key. You would use it like
rdb --command memory /path/to/dump.rdb > keys.csv. The last column in the CSV should be the ttl / expiry.
Only caveat - the version on pip doesn't have this, but the source code is in github. So you just have to install it from source. Github has the instructions.
Using Scan Command
Here is a bash one liner to find keys and their expiry in a CSV format:
redis-cli --scan --pattern "*" | awk '{printf "echo " $1 "\r\nttl " $1 "\r\n"}' | redis-cli --csv | awk '!(NR%2){if($0 > 0) {print p "," $0}}{p=$0}'
The highlighted $0 > 0 in the awk script is for ttl > 0. Modify that to suit your needs. The script will print keys as it find them, you can kill it anytime. The script will run faster if you provide a pattern.
Tip: you can use the above template script to run all kinds of analysis. For example, replace ttl with object idletime to find keys that haven't been used in a while.
Using Commercial RDBTools
If you prefer - RDBTools GUI for Redis (
https://rdbtools.com/) can run the analysis and show you a UI with keys in various expiry buckets.
Disclaimer - I'm the founder.