Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis | redis-cli INFO / avg_ttl value

Tags:

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
like image 299
Jacques Betancourt Avatar asked Oct 06 '14 23:10

Jacques Betancourt


People also ask

How do I check my Redis details?

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.

How can I get total number of keys in Redis?

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.

What is Redis Info command?

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.

How do I find my Redis TTL key?

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.


1 Answers

This is a bit confusing indeed.

  • the TTL command return value is in seconds
  • PTTL command return value is in milliseconds
  • avg_ttl from INFO is in milliseconds

Also, note that this average value avg_ttl is just an estimate based on random check of keys.

like image 160
Arnaud Potier Avatar answered Sep 22 '22 12:09

Arnaud Potier