cache

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedCacheType = errors.New("cache type unsupported")
)

Functions

func Register

func Register(typ string, factory Factory)

func WithContext

func WithContext(ctx context.Context, cch Cache) context.Context

WithContext returns a copy of ctx with cache associated. If a Cache instance is already in the context, the ctx is not updated.

Types

type Cache

type Cache interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error

	Get(ctx context.Context, key string) ([]byte, error)
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
}

func Create

func Create(typ string, config map[string]any, cw watcher.Watcher, co certificate.Observer) (Cache, error)

func Ctx

func Ctx(ctx context.Context) Cache

Ctx returns the Cache associated with the ctx. If no cache is associated, an instance is returned, which does nothing.

type Factory

type Factory interface {
	Create(conf map[string]any, cw watcher.Watcher, co certificate.Observer) (Cache, error)
}

type FactoryFunc

type FactoryFunc func(conf map[string]any, cw watcher.Watcher, co certificate.Observer) (Cache, error)

func (FactoryFunc) Create

func (f FactoryFunc) Create(conf map[string]any, cw watcher.Watcher, co certificate.Observer) (Cache, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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