mcache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultL1TTL = time.Second * 10
	DefaultL2TTL = time.Second * 60
)

Variables

This section is empty.

Functions

func Invalidate

func Invalidate(ctx context.Context, key string) error

func Load

func Load[T any](ctx context.Context, key string, opts *LoadOptions, cb Callback[T], id string) (*T, error)

func Set

func Set(mcache *MCache)

Types

type Callback

type Callback[T any] func(ctx context.Context, id string) (*T, error)

type LoadOptions

type LoadOptions struct {
	DisableLRU bool
}

type MCache

type MCache struct {
	// contains filtered or unexported fields
}

MCache is multiple levels cache

func NewMCache

func NewMCache(opts *Options) *MCache

func (*MCache) Invalidate

func (c *MCache) Invalidate(ctx context.Context, key string) error

func (*MCache) InvalidateL1

func (c *MCache) InvalidateL1(ctx context.Context, key string) error

func (*MCache) InvalidateL2

func (c *MCache) InvalidateL2(ctx context.Context, key string) error

type Options

type Options struct {
	L1Size int
	L1TTL  time.Duration
	L2     cache.Cache
}

Jump to

Keyboard shortcuts

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