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?

Comment From: sundb

@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.

Comment From: mnb4feb

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

Comment From: hulvei3

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/