Thread safe GoLang S(2)LRU cache.
import (
"fmt"
slru "github.com/floatdrop/slru"
)
func main() {
cache := slru.New[string, int](256)
cache.Set("Hello", 5)
if e := cache.Get("Hello"); e != nil {
fmt.Println(*e)
// Output: 5
}
}
floatdrop/slru:
BenchmarkSLRU_Rand-8 5600960 206.9 ns/op 44 B/op 3 allocs/op
BenchmarkSLRU_Freq-8 5927858 201.0 ns/op 43 B/op 3 allocs/op