-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Size method on cache #41
Conversation
@nlachfr qlen is the window size of each shard(window is a very small buffer used in W-TinyLFU, you can read the paper for more detail), not the map size. Also don't forget to add unit test in cache_test.go, you can create a new test case or update TestCost. |
My bad, I only had a quick look at internals, I thought it was the overall shard cost since it is updated during insertion |
@nlachfr The good news is yes, but there are a few things to consider. Firstly, it's not 100% accurate. Secondly, you may need some knowledge of TinyLFU. Theine has two parts: a shared map for storing data, and a policy for determining what to keep and remove when the cache is full.
|
OK, in that case, what do you think I should try to implement ? A function that loops over every item or one that return an approximate of the current state of the cache ? Or both ? For a bit more context, I need this info in order to provide some metrics on cache usage. I have added wrappers around |
@nlachfr I think approximate is good enough, but the method name should show that clearly, something like |
dbc8450
to
d4f2646
Compare
7e227b3
to
1fb8827
Compare
@Yiling-J So, this MR adds two methods on
As you guessed, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. Could you update the README to include the new APIs?
@nlachfr Looks good, Thanks for the contribution🙏 |
Closes #40