MCPcopy Index your code
hub / github.com/CodisLabs/codis / getClientFromCache

Method getClientFromCache

pkg/utils/redis/client.go:387–404  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

385}
386
387func (p *Pool) getClientFromCache(addr string) (*Client, error) {
388 p.mu.Lock()
389 defer p.mu.Unlock()
390 if p.closed {
391 return nil, ErrClosedPool
392 }
393 if list := p.pool[addr]; list != nil {
394 for i := list.Len(); i != 0; i-- {
395 c := list.Remove(list.Front()).(*Client)
396 if p.isRecyclable(c) {
397 return c, nil
398 } else {
399 c.Close()
400 }
401 }
402 }
403 return nil, nil
404}
405
406func (p *Pool) PutClient(c *Client, err error) {
407 p.mu.Lock()

Callers 1

GetClientMethod · 0.95

Calls 3

isRecyclableMethod · 0.95
CloseMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected