cachex

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = errors.New("cache: nil")

ErrNil reply returned by cache when key does not exist.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	Load(ctx context.Context, key string) (any, error)
}

type MultiLevelCache

type MultiLevelCache struct {
}

type ReadThroughCache

type ReadThroughCache struct {
	Store
	Loader Loader
}

func (*ReadThroughCache) Get

func (cache *ReadThroughCache) Get(ctx context.Context, key string) (any, error)

type SingleFlightCache

type SingleFlightCache struct {
	Store Store
	// contains filtered or unexported fields
}

func (*SingleFlightCache) Delete

func (store *SingleFlightCache) Delete(ctx context.Context, key string) error

func (*SingleFlightCache) Get

func (store *SingleFlightCache) Get(ctx context.Context, key string) (any, error)

func (*SingleFlightCache) Set

func (store *SingleFlightCache) Set(ctx context.Context, key string, val any) error

type Store

type Store interface {
	Get(ctx context.Context, key string) (any, error)
	Set(ctx context.Context, key string, val any) error
	Delete(ctx context.Context, key string) error
}

Store 定义接口

func ShardedCache

func ShardedCache(stores []Store) Store

type Updater

type Updater interface {
	Update(ctx context.Context, key string, val any) error
}

type WriteThroughCache

type WriteThroughCache struct {
	Store
	Updater Updater
}

func (*WriteThroughCache) Set

func (cache *WriteThroughCache) Set(ctx context.Context, key string, val any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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