redis

package
v0.0.0-...-2ef7dcc Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 8 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/astaxie/beego/cache/redis"
"github.com/astaxie/beego/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 (
	// The collection name of redis for the cache adapter.
	DefaultKey = "beecacheRedis"
)

Functions

func NewRedisCache

func NewRedisCache() icache.ICache

NewRedisCache creates a new redis cache with default collection name.

Types

type RedisCache

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

Cache is Redis cache adapter.

func (*RedisCache) ClearAll

func (rc *RedisCache) ClearAll() error

ClearAll deletes all cache in the redis collection

func (*RedisCache) Decr

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

Decr decreases a key's counter in redis.

func (*RedisCache) Delete

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

Delete deletes a key's cache in redis.

func (*RedisCache) Get

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

Get cache from redis.

func (*RedisCache) GetMulti

func (rc *RedisCache) GetMulti(keys []string, values []interface{}) (err error)

GetMulti gets cache from redis.

func (*RedisCache) Incr

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

Incr increases a key's counter in redis.

func (*RedisCache) IsExist

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

IsExist checks cache's existence in redis.

func (*RedisCache) Put

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

Put puts cache into redis.

func (*RedisCache) Scan

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

Scan scans all keys matching a given pattern.

func (*RedisCache) StartAndGC

func (rc *RedisCache) 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