cache

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRedisAdapterParams    = errors.New("invalid redis adapter params")
	ErrInvalidMemcacheAdapterParams = errors.New("invalid memcache adapter params")
	ErrInvalidLruAdapterParams      = errors.New("invalid lru adapter params")
	ErrInvalidDefaultName           = errors.New("invalid default name")

	ErrAdapterUndefined      = errors.New("undefined adapter")
	ErrInstanceUninitialized = errors.New("uninitialized instance")
)

Functions

func Forget added in v0.1.6

func Forget(key string) error

func Get added in v0.1.6

func Get(key string, ret any) (bool, error)

func Has added in v0.1.6

func Has(key string) (bool, error)

func HasMulti added in v0.5.5

func HasMulti(keys ...string) (map[string]bool, error)

func Init added in v0.1.6

func Init(conf []Config, defaultAdapter string) error

Init 初始化设置,在框架初始化时调用

func Remember added in v0.1.6

func Remember(key string, value func() (any, error), ttl int64, ret any) (bool, error)

func Set added in v0.2.23

func Set(key string, value any, ttl int64) error

Types

type Cache

type Cache interface {
	Remember(key string, value func() (any, error), ttl int64, ret any) (bool, error)
	Get(key string, ret any) (bool, error)
	Set(key string, value any, ttl int64) error
	Has(key string) (bool, error)
	HasMulti(keys ...string) (map[string]bool, error)
	Forget(key string) error
}

func Instance added in v0.2.23

func Instance(name string) (Cache, error)

Instance 获取缓存实例

type Config added in v0.2.23

type Config struct {
	Name    string            `json:"name" toml:"name"`
	Adapter string            `json:"adapter" toml:"adapter"`
	Option  map[string]string `json:"option" toml:"option"`
}

type Manager added in v0.2.23

type Manager struct {
	sync.Map
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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