Documentation ¶
Index ¶
- type RedisCache
- func (c *RedisCache) Get(key string, data interface{}) bool
- func (c *RedisCache) GetGobBytes(key string) ([]byte, bool)
- func (c *RedisCache) GetInterface(key string) (interface{}, bool)
- func (c *RedisCache) Select(num int)
- func (c *RedisCache) Set(key string, data interface{}) error
- func (c *RedisCache) SetExpire(key string, data interface{}, ttl int64) error
- func (c *RedisCache) SetPrefix(prefix string)
- func (c *RedisCache) SetTTL(ttl int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is a cache source for Redis and contains redis.Pool
func NewRedisCache ¶
func NewRedisCache(pool *redis.Pool) *RedisCache
NewRedisCache returns initialized RedisCache with given redis.Pool
func (*RedisCache) Get ¶
func (c *RedisCache) Get(key string, data interface{}) bool
Get searches cache by given key from redis and returns flag of cache is existed or not. when cache hit, data is assigned.
func (*RedisCache) GetGobBytes ¶
func (c *RedisCache) GetGobBytes(key string) ([]byte, bool)
GetGobBytes searches cache by given key from redis and returns gob-encoded value.
func (*RedisCache) GetInterface ¶
func (c *RedisCache) GetInterface(key string) (interface{}, bool)
GetInterface searches cache by given key from redis and returns interface value.
func (*RedisCache) Select ¶
func (c *RedisCache) Select(num int)
Select sets db number for redis-server
func (*RedisCache) Set ¶
func (c *RedisCache) Set(key string, data interface{}) error
Set sets data into redis. data is wrapped by gob-encoded Item
func (*RedisCache) SetExpire ¶
func (c *RedisCache) SetExpire(key string, data interface{}, ttl int64) error
SetExpire sets data into redis with TTL. data is wrapped by gob-encoded Item
func (*RedisCache) SetPrefix ¶
func (c *RedisCache) SetPrefix(prefix string)
SetPrefix sets the prefix used for adding prefix into key name
func (*RedisCache) SetTTL ¶
func (c *RedisCache) SetTTL(ttl int64)
SetTTL sets default TTL (milliseconds)