redis

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package redis for cache provider

depend on github.com/gomodule/redigo/redis

go install github.com/gomodule/redigo/redis

Usage: import(

_ "github.com/beego/beego/v2/client/cache/redis"
"github.com/beego/beego/v2/client/cache"

)

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

more docs http://beego.me/docs/module/cache.md

Index

Constants

This section is empty.

Variables

View Source
var DefaultKey = "beecacheRedis"

DefaultKey defines the collection name of redis for the cache adapter.

Functions

func NewRedisCache

func NewRedisCache() cache.Cache

NewRedisCache creates a new redis cache with default collection name.

Types

type Cache

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

Cache is Redis cache adapter.

func (*Cache) ClearAll

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

ClearAll deletes all cache in the redis collection Be careful about this method, because it scans all keys and the delete them one by one

func (*Cache) Decr

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

Decr decreases a key's counter in redis.

func (*Cache) Delete

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

Delete deletes a key's cache in redis.

func (*Cache) Get

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

Get cache from redis.

func (*Cache) GetMulti

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

GetMulti gets cache from redis.

func (*Cache) Incr

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

Incr increases a key's counter in redis.

func (*Cache) IsExist

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

IsExist checks cache's existence in redis.

func (*Cache) Put

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

Put puts cache into redis.

func (*Cache) Scan

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

Scan scans all keys matching a given pattern.

func (*Cache) StartAndGC

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

Jump to

Keyboard shortcuts

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