MCPcopy
hub / github.com/redis/go-redis / GetByKey

Method GetByKey

ring.go:451–470  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

449}
450
451func (c *ringSharding) GetByKey(key string) (*ringShard, error) {
452 key = hashtag.Key(key)
453
454 c.mu.RLock()
455 defer c.mu.RUnlock()
456
457 if c.closed {
458 return nil, pool.ErrClosed
459 }
460
461 if c.numShard == 0 {
462 return nil, errRingShardsDown
463 }
464
465 shardName := c.hash.Get(key)
466 if shardName == "" {
467 return nil, errRingShardsDown
468 }
469 return c.shards.m[shardName], nil
470}
471
472func (c *ringSharding) GetByName(shardName string) (*ringShard, error) {
473 if shardName == "" {

Callers 8

RandomMethod · 0.95
SubscribeMethod · 0.80
PSubscribeMethod · 0.80
SSubscribeMethod · 0.80
cmdShardMethod · 0.80
WatchMethod · 0.80
GetShardClientForKeyMethod · 0.80

Calls 2

KeyFunction · 0.92
GetMethod · 0.65

Tested by 1