Back to

package redis

Latest Go to latest
Published: 5 days ago | License: Apache-2.0 | Module:


Package redis for cache provider

depend on

go install

Usage: import(

_ ""


bm, err := cache.NewCache("redis", `{"conn":""}`)

more docs



var (
	// DefaultKey the collection name of redis for cache adapter.
	DefaultKey = "beecacheRedis"

func NewRedisCache

func NewRedisCache() cache.Cache

NewRedisCache create new redis cache with default collection name.

type Cache

type Cache struct {
	// contains filtered or unexported fields

Cache is Redis cache adapter.

func (*Cache) ClearAll

func (rc *Cache) ClearAll() error

ClearAll clean all cache in redis. delete this redis collection.

func (*Cache) Decr

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

Decr decrease counter in redis.

func (*Cache) Delete

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

Delete delete cache in redis.

func (*Cache) Get

func (rc *Cache) Get(key string) interface{}

Get cache from redis.

func (*Cache) GetMulti

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

GetMulti get cache from redis.

func (*Cache) Incr

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

Incr increase counter in redis.

func (*Cache) IsExist

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

IsExist check cache's existence in redis.

func (*Cache) Put

func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error

Put put cache to redis.

func (*Cache) Scan

func (rc *Cache) Scan(pattern string) (keys []string, err error)

Scan scan all keys matching the pattern. a better choice than `keys`

func (*Cache) StartAndGC

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

StartAndGC 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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier