Skip to content
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

is there a function to return the number of hits for an "object"? #82

Open
kolinfluence opened this issue Apr 15, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@kolinfluence
Copy link

kolinfluence commented Apr 15, 2024

e.g. .HitCount() return the number of times the key is hit etc. possible to make it so that it returns both the value and hit count at the same time?

e.g. value, hitcount, err := cache.GetWithHitCount("key")

this will be extremely useful to check if corresponding data should be saved in disk cache etc

@kolinfluence kolinfluence added the enhancement New feature or request label Apr 15, 2024
@maypok86
Copy link
Owner

Unfortunately, I didn't really understand how this will help you determine what data needs to be saved in the disk cache.

@kolinfluence
Copy link
Author

kolinfluence commented Apr 17, 2024

@maypok86 if the hitcount is greater than 4, then only save to disk. else ignore all one hit wonders that has lesser than 3 hits.
choosing what to save to disk saves on disk io and also reduce unnecessary write, extending the lifespan of ssd

p.s. : possible to have this feature? it'll be very useful

@maypok86
Copy link
Owner

It looks relatively useful, but it seems that you don't need exactly hit count. Checking for one-hit wonder is more than enough.

I think I'll try to add this after the v2 release, but it won't be until May. Now I have almost no free time, and my mental health leaves much to be desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants