Caching in Go con 2q
2q è una piccola libreria trhead-safe per il caching in Go.
E' abbastanza semplice da usare, e non ha funzioni avanzate.
Ma può essere utile nel caso di piccoli progetti.
Per l'installazione:
go get github.com/floatdrop/2q
Qui sotto un esempio di codice:
package main
import (
"fmt"
twoqueue "github.com/floatdrop/2q"
)
func main() {
cache := twoqueue.New[string, int](256)
cache.Set("chiave1", 1)
cache.Set("chiave2", 2)
cache.Set("chiave3", 3)
if e := cache.Get("chiave1"); e != nil {
fmt.Println(*e)
}
if e := cache.Get("chiave4"); e != nil {
fmt.Println(*e)
}
}
Enjoy!
go cache 2q
Commentami!