memoize

package
v0.0.0-...-646ff60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2024 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyNoCache = CtxKey("no_cache")
)

Variables

This section is empty.

Functions

func IsNoCache

func IsNoCache(ctx context.Context) bool

func Memoize

func Memoize[REQ any, REPLY any, T func(context.Context, REQ) (REPLY, error)](
	d *MemoizeData,
	fn T,
	ctx context.Context,
	req REQ,
	cacheDuration time.Duration,
) (_ret REPLY, _err error)

func SetNoCache

func SetNoCache(ctx context.Context, b bool) context.Context

Types

type CtxKey

type CtxKey string

type MemoizeData

type MemoizeData struct {
	Cache         map[objhash.ObjHash]any
	CacheMetaLock sync.Mutex
	CacheLockMap  *lockmap.LockMap
}

func NewMemoizeData

func NewMemoizeData() *MemoizeData

func (*MemoizeData) InvalidateCache

func (d *MemoizeData) InvalidateCache(ctx context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL