Closed ouvaa closed 3 months ago
I'm not sure how much of a speedup this will bring, but let me implement it in another branch and test it out.
@phuslu i'm sure you can come up with better. thx in advance. i'm sure it's faster coz byte overhead will be smaller too
the nottl LRU version is available here
go get -v github.com/phuslu/lru@$(git ls-remote https://github.com/phuslu/lru nottl | cut -b-40)
And the benchmark result is here https://github.com/phuslu/lru/actions/runs/8308974059/job/22739812511
Considering the improvement is not too big (+13% throughputs, -20% memory usage), I'd like to keep this implementation just in the "nottl" branch.
Make sense?
are you joking?! the performance is fantastic. -20% mem usage! 13% throughputs! i wonder why cant you just implement as both like NewWithTTL and New (the default without ttl version)
you can do this. where can i buy you coffee?
dont worry about breaking changes, if you are worried, maybe you shld do v2 or v2.0 tag then.
p.s. : i wrote my own lru in cgo for 3 mths. (it's better than yours but with 150ns cgo latency coz of the ffi but within c it's the fastest) and now u made it obsolete. cant thank you enough for this.
@phuslu one last thing, can you do []byte for entries keys and values instead of just string? []byte should be comparable too, not just strings. pls make this "native" and it'll be perfect.
You convinced me. I just renamed the New
function of the master branch to NewTTLCache
. Then, I will introduce the code of the nottl branch.
the first mixed version(LRUCache & TTLCache) is available in latest master branch.
later I will do some tweaks for options and test coverage
can u do a version which i think can be faster if you disregard the time expiry? meaning no time expiry
this is for maximum lru speed. i dont need the expiry field.