Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floatdrop/tannin
https://github.com/floatdrop/tannin
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/floatdrop/tannin
- Owner: floatdrop
- License: mit
- Created: 2022-04-01T10:50:24.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-02T10:13:17.000Z (almost 3 years ago)
- Last Synced: 2024-10-26T21:12:40.868Z (2 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- 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
[![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/tannin.svg)](https://pkg.go.dev/github.com/floatdrop/tannin)
[![build](https://github.com/floatdrop/tannin/actions/workflows/ci.yml/badge.svg)](https://github.com/floatdrop/tannin/actions/workflows/ci.yml)
![Coverage](https://img.shields.io/badge/Coverage-67.5%25-yellow)
[![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/tannin)](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
```