cache

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValueNotExistError    = errors.New("value not exist")
	InvalidValueTypeError = errors.New("invalid value type")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// get cached value by key.
	Get(key string) interface{}
	// GetOrElse return value if it exists, else warmup using warmup function
	GetOrElse(key string, warmUpFunc func(key string) interface{}, expire ...int64) interface{}
	// GetMulti is a batch version of Get.
	GetMulti(keys []string) []interface{}
	// set cached value with key and expire time.
	Set(key string, val interface{}, expire int64)
	// delete cached value by key.
	Delete(key string)
	// increase cached int value by key, as a counter.
	Incr(key string) error
	// decrease cached int value by key, as a counter.
	Decr(key string) error
	// check if cached value exists or not.
	IsExist(key string) bool
	// clear all cache.
	ClearAll()
	// contains filtered or unexported methods
}

func NewMemoryCache

func NewMemoryCache(cfg Config) Cache

func NewRedis

func NewRedis(address, password string) Cache

type Config

type Config struct {
	GcDuration time.Duration
	GcEvery    int //second
}

Jump to

Keyboard shortcuts

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