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

Function newClient

framework/redis/redisutil.go:52–68  ·  view source on GitHub ↗

newClient creates a new go-redis client

(redisURL string, maxIdle, maxActive int)

Source from the content-addressed store, hash-verified

50
51// newClient creates a new go-redis client
52func newClient(redisURL string, maxIdle, maxActive int) *redis.Client {
53 opts := parseRedisURL(redisURL)
54
55 // Map maxIdle/maxActive to go-redis pool settings
56 // go-redis uses MinIdleConns for min idle, PoolSize for max connections
57 if maxIdle <= 0 {
58 maxIdle = defaultMaxIdle
59 }
60 if maxActive <= 0 {
61 maxActive = defaultMaxActive
62 }
63
64 opts.MinIdleConns = maxIdle
65 opts.PoolSize = maxActive
66
67 return redis.NewClient(opts)
68}
69
70// GetDefaultRedisClient returns the RedisClient of specified address
71// use default maxIdle & maxActive

Callers 1

GetRedisClientFunction · 0.85

Calls 1

parseRedisURLFunction · 0.85

Tested by

no test coverage detected