Documentation
¶
Index ¶
- Constants
- func Del(key string) error
- func Get(key string) ([]byte, error)
- func GetRedisClient() *redis.Client
- func GetRedisConfig() *redis.Options
- func IsConnected() bool
- func ResetRedisClient()
- func Set(key string, val interface{}, keyDuration time.Duration) error
- func SetBytes(key string, val []byte, keyDuration time.Duration) error
- type Map
Constants ¶
const ( RedisAddr = "127.0.0.1:6379" RedisPw = "" // no password set RedisDB = 0 // use default DB RedisMaxRetries = 3 // retry number for each get/put operation RedisReConnMaxRetries = 3 // retry number for creating redis client // RedisMinRetryBackoff is min backoff between each retry. -1 disables backoff. RedisMinRetryBackoff = 128 * time.Millisecond // RedisMaxRetryBackoff is max backoff between each retry. -1 disables backoff. RedisMaxRetryBackoff = 512 * time.Millisecond // RedisDialTimeout is the timeout for establishing new connections. RedisDialTimeout = 5 * time.Second // RedisReadTimeout Timeout for socket reads. RedisReadTimeout = 3 * time.Second // RedisWriteTimeout Timeout for socket writes. RedisWriteTimeout = 3 * time.Second RedisKeyDuration = 48 * time.Hour RedisReConnInterval = 15 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Del ¶
Del is a wrapper for redis.Client.Del. It supports asynchronously try to reset the connection to Redis if it fails to delete data.
func Get ¶
Get is a wrapper for redis.Client.Get. It supports asynchronously try to reset the connection to Redis if it fails to get data. If the key doesn't exist in Redis, it returns an empty byte array together with a redis.Nil error
func GetRedisClient ¶
GetRedisClient returns a global instance of redis.Client in singleton model.
func GetRedisConfig ¶
GetRedisConfig returns the global configurationo of Redis in singleton model.
func IsConnected ¶
func IsConnected() bool
IsConnected calls redis.Client.Ping() to verify the connection to Redis.
func ResetRedisClient ¶
func ResetRedisClient()
ResetRedisClient tries to reset the connection to Redis.
Types ¶
type Map ¶
Map is a go-built in map data structure with a read-write lock.
func GetCacheMap ¶
func GetCacheMap() *Map
GetCacheMap is a singleton methond and return the global instance of map cache.