cache

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithCache

func CtxWithCache(ctx context.Context, cache Cache) context.Context

CtxWithCache returns a context derivative with the Cache implementation set to the given one.

Types

type Cache

type Cache interface {
	Get(k any) (any, bool)
	Set(k, v any)
	Reset()
}

Cache is the storage of cached data.

func FromCtx

func FromCtx(ctx context.Context) Cache

FromCtx extracts a Cache implementation from the context, if one is not defined then returns a dummy implementation.

type DummyCache

type DummyCache struct{}

DummyCache is an implementation of Cache, which does not cache anything.

func (DummyCache) Get

func (DummyCache) Get(k any) (any, bool)

func (DummyCache) Reset

func (DummyCache) Reset()

func (DummyCache) Set

func (DummyCache) Set(k, v any)

Jump to

Keyboard shortcuts

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