Categorygithub.com/floatdrop/tannin
repositorypackage
0.0.0
Repository: https://github.com/floatdrop/tannin.git
Documentation: pkg.go.dev

# README

tannin

Go Reference build Coverage Go Report Card

Tannin is implementation of W-TinyLRU cache, that was implemented in Caffeine as eviction policy. Later it was adopted to Ristretto cache library.

Example

import (
	"fmt"

	tannin "github.com/floatdrop/tannin"
)

func main() {
	cache := tannin.New[string, int](256, 100)

	cache.Set("Hello", 5)

	if e := cache.Get("Hello"); e != nil {
		fmt.Println(*e)
		// Output: 5
	}
}

Benchmarks

floatdrop/tannin
	BenchmarkTannin_Rand-8   	 3957745	       295.8 ns/op	      84 B/op	       7 allocs/op
	BenchmarkTannin_Freq-8   	 4598648	       255.7 ns/op	      78 B/op	       7 allocs/op