cache

package
v0.0.0-...-a4359f9 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found in cache")
)

Errors

Functions

This section is empty.

Types

type Auto

type Auto struct {
	Tracer   *tracing.Tracer
	Provider Provider
	Loader   LoaderFunc
	// contains filtered or unexported fields
}

Auto is a cache that automatically attempts to load objects if they don't exist

func (*Auto) Get

func (a *Auto) Get(ctx context.Context, key string) (data []byte, err error)

Get returns an object from the cache if it exists, otherwise it loads it into the cache and returns it

type LoaderFunc

type LoaderFunc func(ctx context.Context, key string) (data []byte, err error)

LoaderFunc is a function for loading data into a cache

type Provider

type Provider interface {
	Get(ctx context.Context, key string) (data []byte, err error)
	Set(ctx context.Context, key string, data []byte) (err error)
	Shutdown()
}

Provider is an interface for getting and setting cached objects

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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