cache

package
v0.8.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Provide(
	fx.Annotate(
		newCache,
		fx.OnStart(func(ctx context.Context, cch Cache) error { return cch.Start(ctx) }),
		fx.OnStop(func(ctx context.Context, cch Cache) error { return cch.Stop(ctx) }),
	),
)

nolint

Functions

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 {
	Evictor

	Get(key string) any
	Set(key string, value any, ttl time.Duration)
	Delete(key string)
}

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 Evictor

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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