beego: Index | Files

package redis

import ""

Package redis for cache provider

depend on

go install

Usage: import(

_ ""


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

more docs


Package Files



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

func NewRedisCache Uses

func NewRedisCache() cache.Cache

NewRedisCache creates a new redis cache with default collection name.

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields

Cache is Redis cache adapter.

func (*Cache) ClearAll Uses

func (rc *Cache) ClearAll(context.Context) error

ClearAll deletes all cache in the redis collection

func (*Cache) Decr Uses

func (rc *Cache) Decr(ctx context.Context, key string) error

Decr decreases a key's counter in redis.

func (*Cache) Delete Uses

func (rc *Cache) Delete(ctx context.Context, key string) error

Delete deletes a key's cache in redis.

func (*Cache) Get Uses

func (rc *Cache) Get(ctx context.Context, key string) (interface{}, error)

Get cache from redis.

func (*Cache) GetMulti Uses

func (rc *Cache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error)

GetMulti gets cache from redis.

func (*Cache) Incr Uses

func (rc *Cache) Incr(ctx context.Context, key string) error

Incr increases a key's counter in redis.

func (*Cache) IsExist Uses

func (rc *Cache) IsExist(ctx context.Context, key string) (bool, error)

IsExist checks cache's existence in redis.

func (*Cache) Put Uses

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

Put puts cache into redis.

func (*Cache) Scan Uses

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

Scan scans all keys matching a given pattern.

func (*Cache) StartAndGC Uses

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

StartAndGC starts the redis cache adapter. config: must be in this format {"key":"collection key","conn":"connection info","dbNum":"0"} Cached items in redis are stored forever, no garbage collection happens

Package redis imports 9 packages (graph) and is imported by 1 packages. Updated 2020-12-01. Refresh now. Tools for package owners.