MCPcopy Create free account
hub / github.com/devfeel/dotweb / GetRedisClient

Function GetRedisClient

framework/redis/redisutil.go:77–104  ·  view source on GitHub ↗

GetRedisClient returns the RedisClient of specified address & maxIdle & maxActive

(address string, maxIdle, maxActive int)

Source from the content-addressed store, hash-verified

75
76// GetRedisClient returns the RedisClient of specified address & maxIdle & maxActive
77func GetRedisClient(address string, maxIdle, maxActive int) *RedisClient {
78 if maxIdle <= 0 {
79 maxIdle = defaultMaxIdle
80 }
81 if maxActive <= 0 {
82 maxActive = defaultMaxActive
83 }
84
85 var rc *RedisClient
86 var mok bool
87
88 mapMutex.RLock()
89 rc, mok = redisMap[address]
90 mapMutex.RUnlock()
91
92 if !mok {
93 rc = &RedisClient{
94 Address: address,
95 client: newClient(address, maxIdle, maxActive),
96 maxIdle: maxIdle,
97 maxActive: maxActive,
98 }
99 mapMutex.Lock()
100 redisMap[address] = rc
101 mapMutex.Unlock()
102 }
103 return rc
104}
105
106// GetObj returns the content specified by key
107func (rc *RedisClient) GetObj(key string) (interface{}, error) {

Callers 3

GetDefaultRedisClientFunction · 0.85

Calls 1

newClientFunction · 0.85

Tested by 2