Skip to content

Commit 6d8232e

Browse files
authored
Merge branch 'master' into perf/reduce-memory-allocation
2 parents f02599c + 0f40ae3 commit 6d8232e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ring.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,12 @@ func (c *ringSharding) GetByName(shardName string) (*ringShard, error) {
405405
c.mu.RLock()
406406
defer c.mu.RUnlock()
407407

408-
return c.shards.m[shardName], nil
408+
shard, ok := c.shards.m[shardName]
409+
if !ok {
410+
return nil, errors.New("redis: the shard is not in the ring")
411+
}
412+
413+
return shard, nil
409414
}
410415

411416
func (c *ringSharding) Random() (*ringShard, error) {

0 commit comments

Comments
 (0)