Documentation
¶
Index ¶
- Variables
- func Init(cacheName string)
- type GoCache
- func (g *GoCache) Add(key string, delta int64) error
- func (g *GoCache) ClearAll() error
- func (g *GoCache) Decr(key string) error
- func (g *GoCache) Delete(key string) error
- func (g *GoCache) Get(key string) (interface{}, error)
- func (g *GoCache) GetMulti(keys []string) []interface{}
- func (g *GoCache) Incr(key string) error
- func (g *GoCache) IsExist(key string) bool
- func (g *GoCache) Put(key string, val interface{}) error
- func (g *GoCache) PutWithTimeout(key string, val interface{}, timeout int64) error
- type ICache
- type RedisCache
- func (rc *RedisCache) Add(key string, delta int64) error
- 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) (interface{}, error)
- func (rc *RedisCache) GetMulti(keys []string) []interface{}
- func (rc *RedisCache) Incr(key string) error
- func (rc *RedisCache) IsExist(key string) bool
- func (rc *RedisCache) Put(key string, val interface{}) error
- func (rc *RedisCache) PutWithTimeout(key string, val interface{}, timeout int64) error
- func (rc *RedisCache) StartAndGC(config string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrObjectNotFound = errors.New("not found") ErrObjectNotNumber = errors.New("not a number") )
View Source
var ( // the collection name of redis for cache adapter. DefaultRedisKey = "avegeConsole" RedisServer = "127.0.0.1:6379" )
Functions ¶
Types ¶
type ICache ¶
type ICache interface {
Get(key string) (interface{}, error)
GetMulti(keys []string) []interface{}
PutWithTimeout(key string, val interface{}, timeout int64) error
Put(key string, val interface{}) error
Delete(key string) error
IsExist(key string) bool
Add(key string, delta int64) error
Incr(key string) error
Decr(key string) error
ClearAll() error
}
var ( // Instance default ICache instance Instance ICache )
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
Redis cache adapter.
func (*RedisCache) ClearAll ¶
func (rc *RedisCache) ClearAll() error
clean all cache in redis. delete this redis collection.
func (*RedisCache) Get ¶
func (rc *RedisCache) Get(key string) (interface{}, error)
Get cache from redis.
func (*RedisCache) GetMulti ¶
func (rc *RedisCache) GetMulti(keys []string) []interface{}
GetMulti get cache from redis.
func (*RedisCache) IsExist ¶
func (rc *RedisCache) IsExist(key string) bool
check cache's existence in redis.
func (*RedisCache) Put ¶
func (rc *RedisCache) Put(key string, val interface{}) error
func (*RedisCache) PutWithTimeout ¶
func (rc *RedisCache) PutWithTimeout(key string, val interface{}, timeout int64) error
put cache to redis.
func (*RedisCache) StartAndGC ¶
func (rc *RedisCache) StartAndGC(config string) error
start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbNum":"0"} the cache item in redis are stored forever, so no gc operation.
Click to show internal directories.
Click to hide internal directories.