Skip to content

Commit

Permalink
v0.4.2, consider the case when m.cfg is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
superisaac committed May 27, 2024
1 parent dbc1fc1 commit 01443d4
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions core/redisutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ func (m *Multiplexer) RedisClient(selector string) (c *redis.Client, ok bool) {
return c, ok
}

if store, ok := m.cfg.Stores[selector]; ok && store.Scheme() == "redis" {
opts, err := GetRedisOptions(store.Url)
if err != nil {
log.Panicf("parse redis option error, url=%s, %s", store.Url, err)
return nil, false
if m.cfg != nil && m.cfg.Stores != nil {
if store, ok := m.cfg.Stores[selector]; ok && store.Scheme() == "redis" {
opts, err := GetRedisOptions(store.Url)
if err != nil {
log.Panicf("parse redis option error, url=%s, %s", store.Url, err)
return nil, false
}
c := redis.NewClient(opts)
m.redisClients[selector] = c
return c, true
}
c := redis.NewClient(opts)
m.redisClients[selector] = c
return c, true
}

if selector != "default" {
Expand All @@ -63,16 +65,17 @@ func (m *Multiplexer) RedisClientExact(selector string) (c *redis.Client, ok boo
if c, ok := m.redisClients[selector]; ok {
return c, ok
}

if store, ok := m.cfg.Stores[selector]; ok && store.Scheme() == "redis" {
opts, err := GetRedisOptions(store.Url)
if err != nil {
log.Panicf("parse redis option error, url=%s, %s", store.Url, err)
return nil, false
if m.cfg != nil && m.cfg.Stores != nil {
if store, ok := m.cfg.Stores[selector]; ok && store.Scheme() == "redis" {
opts, err := GetRedisOptions(store.Url)
if err != nil {
log.Panicf("parse redis option error, url=%s, %s", store.Url, err)
return nil, false
}
c := redis.NewClient(opts)
m.redisClients[selector] = c
return c, true
}
c := redis.NewClient(opts)
m.redisClients[selector] = c
return c, true
}

return nil, false
Expand Down

0 comments on commit 01443d4

Please sign in to comment.