al8n / stretto

Stretto is a Rust implementation for Dgraph's ristretto (https://github.com/dgraph-io/ristretto). A high performance memory-bound Rust cache.
Apache License 2.0
413 stars 28 forks source link

How to print `sync::cache` state #26

Closed kakoc closed 2 years ago

kakoc commented 2 years ago

Suppose I have a sync::Cache<_, _> and I'd like to display its content(for example for debugging purposes). How can I do that? I didn't find any way.

al8n commented 2 years ago

Hi, which stats you want to print? Currently, this crate does not provide any iter for users to view all of the data in the cache.

kakoc commented 2 years ago

I'd like to see key: value pairs

al8n commented 2 years ago

If you want to see how many key: value pairs are in the cache, I can add the functionality. But if you want to see something like key1: value1 key2: value2, and etc, we seem to cannot do it because of the cache design. But you can implement a custom CacheCallback. I think it can give you the equivalent functionality.