otter icon indicating copy to clipboard operation
otter copied to clipboard

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

Open kolinfluence opened this issue 10 months ago • 3 comments

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 avatar Apr 15 '24 01:04 kolinfluence

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

maypok86 avatar Apr 15 '24 10:04 maypok86

@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

kolinfluence avatar Apr 17 '24 01:04 kolinfluence

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.

maypok86 avatar Apr 21 '24 12:04 maypok86