dgraph-io / ristretto

A high performance memory-bound Go cache
https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/
Apache License 2.0
5.64k stars 374 forks source link

Proposal: add metrics KeysNumber #135

Closed choleraehyq closed 4 years ago

choleraehyq commented 4 years ago

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

martinmr commented 4 years ago

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.

blasrodri commented 4 years ago

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

minhaj-shakeel commented 4 years ago

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