cache

package
v0.0.0-...-108e96f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrObjectNotFound  = errors.New("not found")
	ErrObjectNotNumber = errors.New("not a number")
)
View Source
var (
	// the collection name of redis for cache adapter.
	DefaultRedisKey = "avegeConsole"
	RedisServer     = "127.0.0.1:6379"
)

Functions

func Init

func Init(cacheName string)

Types

type GoCache

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

func (*GoCache) Add

func (g *GoCache) Add(key string, delta int64) error

func (*GoCache) ClearAll

func (g *GoCache) ClearAll() error

func (*GoCache) Decr

func (g *GoCache) Decr(key string) error

func (*GoCache) Delete

func (g *GoCache) Delete(key string) error

func (*GoCache) Get

func (g *GoCache) Get(key string) (interface{}, error)

func (*GoCache) GetMulti

func (g *GoCache) GetMulti(keys []string) []interface{}

func (*GoCache) Incr

func (g *GoCache) Incr(key string) error

func (*GoCache) IsExist

func (g *GoCache) IsExist(key string) bool

func (*GoCache) Put

func (g *GoCache) Put(key string, val interface{}) error

func (*GoCache) PutWithTimeout

func (g *GoCache) PutWithTimeout(key string, val interface{}, timeout int64) error

type ICache

type ICache interface {
	Get(key string) (interface{}, error)
	GetMulti(keys []string) []interface{}
	PutWithTimeout(key string, val interface{}, timeout int64) error
	Put(key string, val interface{}) error
	Delete(key string) error
	IsExist(key string) bool
	Add(key string, delta int64) error
	Incr(key string) error
	Decr(key string) error
	ClearAll() error
}
var (

	// Instance default ICache instance
	Instance ICache
)

func FindCache

func FindCache(cacheName string) ICache

type RedisCache

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

Redis cache adapter.

func (*RedisCache) Add

func (rc *RedisCache) Add(key string, delta int64) error

func (*RedisCache) ClearAll

func (rc *RedisCache) ClearAll() error

clean all cache in redis. delete this redis collection.

func (*RedisCache) Decr

func (rc *RedisCache) Decr(key string) error

decrease counter in redis.

func (*RedisCache) Delete

func (rc *RedisCache) Delete(key string) error

delete cache in redis.

func (*RedisCache) Get

func (rc *RedisCache) Get(key string) (interface{}, error)

Get cache from redis.

func (*RedisCache) GetMulti

func (rc *RedisCache) GetMulti(keys []string) []interface{}

GetMulti get cache from redis.

func (*RedisCache) Incr

func (rc *RedisCache) Incr(key string) error

increase counter in redis.

func (*RedisCache) IsExist

func (rc *RedisCache) IsExist(key string) bool

check cache's existence in redis.

func (*RedisCache) Put

func (rc *RedisCache) Put(key string, val interface{}) error

func (*RedisCache) PutWithTimeout

func (rc *RedisCache) PutWithTimeout(key string, val interface{}, timeout int64) error

put cache to redis.

func (*RedisCache) StartAndGC

func (rc *RedisCache) StartAndGC(config string) error

start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbNum":"0"} the cache item in redis are stored forever, so no gc operation.

Jump to

Keyboard shortcuts

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