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 ¶
- Variables
- func NewRedisCache() icache.ICache
- type RedisCache
- func (rc *RedisCache) ClearAll() error
- func (rc *RedisCache) Decr(key string) error
- func (rc *RedisCache) Delete(key string) error
- func (rc *RedisCache) Get(key string, value interface{}) (err error)
- func (rc *RedisCache) GetMulti(keys []string, values []interface{}) (err error)
- func (rc *RedisCache) Incr(key string) error
- func (rc *RedisCache) IsExist(key string) (bool, error)
- func (rc *RedisCache) Put(key string, val interface{}, timeout time.Duration) error
- func (rc *RedisCache) Scan(pattern string) (keys []string, err error)
- func (rc *RedisCache) StartAndGC(config string) error
Constants ¶
This section is empty.
Variables ¶
var (
// The collection name of redis for the cache adapter.
DefaultKey = "beecacheRedis"
)
Functions ¶
func NewRedisCache ¶
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