eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches
https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/
MIT License
2.46k stars 195 forks source link

Fixing Rueidis store implementation #185

Closed rwrz closed 1 year ago

rwrz commented 1 year ago

Hey @eko , thanks for doing that and sorry for taking so long to include the tests. I'm adding a new test for NotFound, just to ensure it is working as intended. Also, fixing the idea of the clientExpiration option I've done in the previous proposal. The idea here is to keep the expiration using TTL (server-side), but give an option to the user to use a different expiration time for the server-assisted client cache (more info on the link below).

Commit notes:

Adding ClientSideCacheExpiration option for rueidis, tweaking tests and benchmarks.

Benchmark Results:

goos: linux
goarch: amd64
pkg: github.com/eko/gocache/v4/store/rueidis
cpu: AMD Ryzen 5 1600 Six-Core Processor            
BenchmarkRueidisSet
BenchmarkRueidisSet/1
BenchmarkRueidisSet/1-12        6164        243191 ns/op
BenchmarkRueidisSet/2
BenchmarkRueidisSet/2-12        3741        463155 ns/op
BenchmarkRueidisSet/4
BenchmarkRueidisSet/4-12        1765        719615 ns/op
BenchmarkRueidisSet/8
BenchmarkRueidisSet/8-12         897       1371644 ns/op
BenchmarkRueidisSet/16
BenchmarkRueidisSet/16-12        397       4154892 ns/op
BenchmarkRueidisSet/32
BenchmarkRueidisSet/32-12        224       6195236 ns/op
BenchmarkRueidisSet/64
BenchmarkRueidisSet/64-12        100      13440387 ns/op
BenchmarkRueidisSet/128
BenchmarkRueidisSet/128-12                38      26693594 ns/op
BenchmarkRueidisSet/256
BenchmarkRueidisSet/256-12                16      64581190 ns/op
BenchmarkRueidisSet/512
BenchmarkRueidisSet/512-12                10     113861449 ns/op
BenchmarkRueidisSet/1024
BenchmarkRueidisSet/1024-12                5     208020637 ns/op
BenchmarkRueidisGet
BenchmarkRueidisGet/1
BenchmarkRueidisGet/1-12             2415909           620.8 ns/op
BenchmarkRueidisGet/2
BenchmarkRueidisGet/2-12             1023564          1205 ns/op
BenchmarkRueidisGet/4
BenchmarkRueidisGet/4-12              499236          2372 ns/op
BenchmarkRueidisGet/8
BenchmarkRueidisGet/8-12              270166          4725 ns/op
BenchmarkRueidisGet/16
BenchmarkRueidisGet/16-12             112500          9645 ns/op
BenchmarkRueidisGet/32
BenchmarkRueidisGet/32-12              56277         18923 ns/op
BenchmarkRueidisGet/64
BenchmarkRueidisGet/64-12              30972         42437 ns/op
BenchmarkRueidisGet/128
BenchmarkRueidisGet/128-12             16580         77926 ns/op
BenchmarkRueidisGet/256
BenchmarkRueidisGet/256-12              6326        168652 ns/op
BenchmarkRueidisGet/512
BenchmarkRueidisGet/512-12              3812        319607 ns/op
BenchmarkRueidisGet/1024
BenchmarkRueidisGet/1024-12             2150        624327 ns/op
PASS