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.54k stars 364 forks source link

`fix(OnEvict)`: Set missing Expiration field on evicted items #345

Closed 0x1ee7 closed 1 year ago

0x1ee7 commented 1 year ago

On our use case we need to rely on expiration timestamps but we realized that they return zero timestamps. Our assumption is that this is due to a bug and not by design.

Problem

When OnEvict callback is executed Item does not have Expiration field set. Considering it is a public field this needs to be set and available.

Solution

Initialize Expiration field before calling the onEvict callback

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.