type-cacheable icon indicating copy to clipboard operation
type-cacheable copied to clipboard

Cache hit / miss rate

Open herebebogans opened this issue 3 years ago • 3 comments

Love this library!

At the moment there appears to be no hooks to determine if the cached key lookup was a hit or a miss or the number of times a key has been accessed ? Any thoughts on an interface to view these stats?

herebebogans avatar Aug 07 '20 08:08 herebebogans

Thanks!

Could you provide me with the stats you'd find helpful?

hits: 10,
misses: 5,

Do you need more information to be stored? For example:

hits: {
  methodName: 10,
},
misses: {
  methodName: 5,
},

Or even more, down to the key name?

joshuaslate avatar Aug 07 '20 14:08 joshuaslate

To start with overall and by method but eventually by key would also be useful.

I'm not sure if this would be possible but in addition to counts for hits and misses, a request rate per second?

eg Overall

summary: {
  hits: {
    rate: 0.5,
    count: 100,
 }, 
  misses: {
    rate: 0.1,
    count: 20
  },
}

If you look at node-cache

https://github.com/ptarjan/node-cache/blob/master/index.js

It exposes a simple .hits() and .misses() method that's only populated when running with a debug flag.

herebebogans avatar Aug 08 '20 00:08 herebebogans