cache

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 11 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")
	ErrAdapterUninitialized = errors.New("uninitialized adapter")
)

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 interface{}) (bool, error)

func Has added in v0.1.6

func Has(key 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() (interface{}, error), ttl int64, ret interface{}) (bool, error)

func Set added in v0.2.23

func Set(key string, value interface{}, ttl int64) error

Types

type Cache

type Cache interface {
	Remember(key string, value func() (interface{}, error), ttl int64, ret interface{}) (bool, error)
	Get(key string, ret interface{}) (bool, error)
	Set(key string, value interface{}, ttl int64) error
	Has(key 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