Skip to content

mycrEEpy/mempot

Repository files navigation

mempot

Go Reference Go Report Card Go Build & Test Go Coverage

mempot

mempot is a small and easy generic memory cache for Go.

Usage

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)
}

About

mempot is a small and easy generic memory cache for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published