P. Paul
P. Paul

Reputation: 403

Queries frequency stats in Redis?

In my application I am implementing a server-side cache using Redis (for mySQL database). When data change in the database, I want to completely clear the cache to invalidate the old data.

However, I would like to see some statistics about how often are different keys queried in Redis, so that I can sort of manually pre-fetch frequently queried data for them to be available immediately after clearing the cache.

Is there any way how to see these statistics directly in Redis? Or what is a common solution to this problem?

Upvotes: 1

Views: 1755

Answers (2)

Fify
Fify

Reputation: 141

redis-cli --hotkeys can do the help for redis-cli version 4.x and above.

Upvotes: 2

LeoMurillo
LeoMurillo

Reputation: 6764

You can use the object command.

OBJECT FREQ returns the logarithmic access frequency counter of the object stored at the specified key. This subcommand is available when maxmemory-policy is set to an LFU policy.

https://redis.io/commands/object

Upvotes: 3

Related Questions