Categorygithub.com/floatdrop/slru
repositorypackage
0.1.0
Repository: https://github.com/floatdrop/slru.git
Documentation: pkg.go.dev

# README

slru

Go Reference CI Coverage Go Report Card

Thread safe GoLang S(2)LRU cache.

Example

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
	}
}

Benchmarks

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