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/whiliang/beego-multi-schema/v2/client/cache/redis" "github.com/whiliang/beego-multi-schema/v2/client/cache"
)
bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`) more docs http://beego.vip/docs/module/cache.md
Index ¶
- Variables
- func NewRedisCache() cache.Cache
- type Cache
- func (rc *Cache) ClearAll(context.Context) error
- func (rc *Cache) Decr(ctx context.Context, key string) error
- func (rc *Cache) Delete(ctx context.Context, key string) error
- func (rc *Cache) Get(ctx context.Context, key string) (interface{}, error)
- func (rc *Cache) GetMulti(ctx context.Context, keys []string) ([]interface{}, error)
- func (rc *Cache) Incr(ctx context.Context, key string) error
- func (rc *Cache) IsExist(ctx context.Context, key string) (bool, error)
- func (rc *Cache) Put(ctx context.Context, key string, val interface{}, timeout time.Duration) error
- func (rc *Cache) Scan(pattern string) (keys []string, err error)
- func (rc *Cache) StartAndGC(config string) error
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 ¶
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 ¶
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) StartAndGC ¶
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
Click to show internal directories.
Click to hide internal directories.