
mempot
is a small and easy generic memory cache for Go.
package main
import (
"context"
"fmt"
"github.com/mycreepy/mempot"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cache := mempot.NewCache[string, string](ctx, mempot.DefaultConfig)
cache.Set("foo", "bar")
item, ok := cache.Get("foo")
if !ok {
panic("item not found or expired")
}
fmt.Println(item.Data)
}