MCPcopy Create free account
hub / github.com/LockGit/gochat / GetRedisInstance

Function GetRedisInstance

tools/redis.go:24–42  ·  view source on GitHub ↗
(redisOpt RedisOption)

Source from the content-addressed store, hash-verified

22}
23
24func GetRedisInstance(redisOpt RedisOption) *redis.Client {
25 address := redisOpt.Address
26 db := redisOpt.Db
27 password := redisOpt.Password
28 addr := fmt.Sprintf("%s", address)
29 syncLock.Lock()
30 if redisCli, ok := RedisClientMap[addr]; ok {
31 return redisCli
32 }
33 client := redis.NewClient(&redis.Options{
34 Addr: addr,
35 Password: password,
36 DB: db,
37 MaxConnAge: 20 * time.Second,
38 })
39 RedisClientMap[addr] = client
40 syncLock.Unlock()
41 return RedisClientMap[addr]
42}

Callers 3

Test_TestQueueFunction · 0.92
InitQueueRedisClientMethod · 0.92

Calls

no outgoing calls

Tested by 1

Test_TestQueueFunction · 0.74