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

Add ability to hook into the "eviction" event

GiedriusS opened this issue · comments

Please provide another member onEvict in the Config struct which would be a function that would be called on eviction if it is present. This is needed so that users would be able to do some more, extra house-keeping from their side.

completed in #23

@karlmcguire awesome, thanks a lot! We will try to use this in the https://github.com/thanos-io/thanos project instead of a simple, LRU based cache -- the performance should improve a lot since because of the nature of requests coming into it a lot of the same cache items are used over and over again, and the simple LRU cache works badly with that.

Why was it removed? 😞

We switched to using uint64 keys internally so there's no way to derive strings from the list victims. I apologize, but we're still still moving a lot of things around and if the opportunity arises we'll add it back.

Why was this closed? I understand what you've said but maybe at least this could be added for the values of victims? Also, this is a corollary but is there any way to get the "metrics" from ristretto? AFAICT you can only specify ATM if you want metrics to be collected but there is no way to get it from outside the package. That could be at least a partial solution to this problem - we want to expose some metrics from the cache to the outside world.

metrics func should be exposed. Looks like there was an oversight on my part to make it private.

@jarifibrahim ^

I'll look into this issue.

This has been fixed via #47 .