cache

package
v1.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvalidateAll

func InvalidateAll()

InvalidateAll 删除所有缓存值,只用于单元测试。

func Load

func Load(ctx context.Context, key string, loader Loader, opts ...Option) (loadType LoadType, result Result, err error)

Types

type LoadType

type LoadType int
const (
	LoadNone  LoadType = iota // 获取失败
	LoadOnCtx                 // 从 context.Context 缓存获取
	LoadCache                 // 从本地缓存的值获取
	LoadBack                  // 从用户回调中获取
)

type Loader

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

type Option

type Option func(*optionArg)

func ExpireAfterWrite

func ExpireAfterWrite(v time.Duration) Option

type Result

type Result interface {
	Json() string
	Load(v interface{}) error
}

type ResultLoader

type ResultLoader func(ctx context.Context, key string) (Result, LoadType, error)

Jump to

Keyboard shortcuts

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