When I run the command redis-cli INFO
, one of the returned values indicates the avg_ttl
. I'm unsure what unit of time this is represented in?
Example:
# Keyspace
db0:keys=706818,expires=228745,avg_ttl=1521990750
Redis Key Memory Info You can use two main commands if you want to view the keys in a Redis datastore. Dbsize – The Redis dbsize command shows the total number of valid keys in a specific database. Info keyspace – This command shows the keys in each database available in the Redis cluster.
The first command you can use to get the total number of keys in a Redis database is the DBSIZE command. This simple command should return the total number of keys in a selected database as an integer value. The above example command shows that there are 203 keys in the database at index 10.
The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans. The optional parameter can be used to select a specific section of information: server : General information about the Redis server. clients : Client connections section.
First, create a key in redis and set some value in it. Now set the expiry of the key and after that just check the remaining expiry time. First, create a key in redis and set some value in it. Now set the expiry of the key, and after that just check the remaining expiry time.
This is a bit confusing indeed.
Also, note that this average value avg_ttl is just an estimate based on random check of keys.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With