https://github.com/floatdrop/tannin
https://github.com/floatdrop/tannin
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/floatdrop/tannin
- Owner: floatdrop
- License: mit
- Created: 2022-04-01T10:50:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-02T10:13:17.000Z (over 3 years ago)
- Last Synced: 2025-03-14T01:31:43.573Z (4 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# tannin
[](https://pkg.go.dev/github.com/floatdrop/tannin)
[](https://github.com/floatdrop/tannin/actions/workflows/ci.yml)

[](https://goreportcard.com/report/github.com/floatdrop/tannin)Tannin is implementation of [W-TinyLRU](https://arxiv.org/pdf/1512.00727.pdf) cache, that was implemented in [Caffeine](https://github.com/ben-manes/caffeine) as eviction policy. Later it was adopted to [Ristretto](https://github.com/dgraph-io/ristretto) cache library.
## Example
```go
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
```