Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Get cache-hit ratio for a cache key / cache key pattern (and not just the entire keyspace) #9965

Open
geeky-biz opened this issue Dec 20, 2021 · 3 comments

Comments

@geeky-biz
Copy link

The problem/use-case that the feature addresses

We use Redis to cache (dynamically generated) HTML responses for our website. Our website contains forum, content pages, administration section, etc. So - the (programmatic) caching policy for each of these sections differs heavily. The caching policy can also differ if a user is logged-in, admin or anonymous, etc.

We seek to find out the cache-hit ratio for one or a group of cache keys. Say - our website section X has cache key starting with "website_X_". How can we get the cache-hit ratio for a single key or a key pattern (like "website_X_*") instead of the entire keyspace that works currently.

Description of the feature

The most ideal way to consume this would be through an INFO command (or a similar command) but for a key pattern and not for the entire keyspace.

Alternatives you've considered

One alternative we are considering is to emit cache hit and misses from the redis cache consumer to some place and then summarize that data. Is this the best possible approach in the current setup?

@sundb
Copy link
Collaborator

sundb commented Dec 21, 2021

@geeky-biz The only simplest way I can think of should be to put different types of caches in different dbs,
so that you can know the hit ratios of different types of caches through INFO.
Take me back, hits belong to all dbs.

@mnb4feb
Copy link

mnb4feb commented Jul 5, 2022

Hi @geeky-biz , Have you got an answer for this ?

@hulvei3
Copy link

hulvei3 commented Sep 21, 2022

We also have seen the need to aggregate cache hit/miss on a specific pattern

One approach could be to add additional keyspace notifications to accommodate this, similar to how Key miss events are raised according to https://redis.io/docs/manual/keyspace-notifications/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants