Does ristretto fires event when ttl expires

Team,

I’m making an app where I have to save data in db and ristretto as well. Does ristretto fires any event on ttl expiration of an object. It would be easier to manage the db in parallel.

Especially in oauth servers this is needed.

@mrjn, @ibrahim. I would be grateful if you can suggest here.

You can set a func for OnEvict which gets called every time a cached key gets evicted (like when a TTL expires). GitHub - dgraph-io/ristretto: A high performance memory-bound Go cache

Oops. sorry I just missed that. Thanks a lot for help.

Sorry for being little lazy but just a quick question, consider I save string type key values in ristretto
key=“Name”
Value=“Daniel”
Cost=1

As per this definition, func(hashes [2]uint64, value interface{}, cost int64), what will be the value of these parameters:

hashes array and value

@smartaquarius10 looks like our readme is out of date. You’ll have to set the OnEvict function which accepts an *ristretto.Item

See this for an example of how to use it

Hey @ibrahim,

Thanks a lot for sharing. This one what I wanted so that I can remove the same value from my actual storage DB.

Thank you :slight_smile:

1 Like