dgraph-io / ristretto

A high performance memory-bound Go cache

Home Page:https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: add metrics KeysNumber

choleraehyq opened this issue · comments

Here I want to get the key numbers current cache contains. Seems it's easy to maintain.

Just to make sure we are on the same page you want Ristretto to report the current number of key-value pairs stored in the cache.

This would be easy to code but it's not as straight-forward as the other metrics because Ristretto uses a sharded map so we'd need to iterate through the maps (while holding the locks for each shard) so there are performance implications. All the other metrics are reported via atomic counters which means there's no locking involved.

I'll bring it up to @manishrjain to see what he thinks.

@martinmr would it be possible to store an atomic integer that reflects this number, and gets updated every time a key is added/evicted?

Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing