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

Method handleRequestExists

pkg/proxy/session.go:506–546  ·  view source on GitHub ↗
(r *Request, d *Router)

Source from the content-addressed store, hash-verified

504}
505
506func (s *Session) handleRequestExists(r *Request, d *Router) error {
507 var nkeys = len(r.Multi) - 1
508 switch {
509 case nkeys == 0:
510 r.Resp = redis.NewErrorf("ERR wrong number of arguments for 'EXISTS' command")
511 return nil
512 case nkeys == 1:
513 return d.dispatch(r)
514 }
515 var sub = r.MakeSubRequest(nkeys)
516 for i := range sub {
517 sub[i].Multi = []*redis.Resp{
518 r.Multi[0],
519 r.Multi[i+1],
520 }
521 if err := d.dispatch(&sub[i]); err != nil {
522 return err
523 }
524 }
525 r.Coalesce = func() error {
526 var n int
527 for i := range sub {
528 if err := sub[i].Err; err != nil {
529 return err
530 }
531 switch resp := sub[i].Resp; {
532 case resp == nil:
533 return ErrRespIsRequired
534 case resp.IsInt() && len(resp.Value) == 1:
535 if resp.Value[0] != '0' {
536 n++
537 }
538 default:
539 return fmt.Errorf("bad exists resp: %s value.len = %d", resp.Type, len(resp.Value))
540 }
541 }
542 r.Resp = redis.NewInt(strconv.AppendInt(nil, int64(n), 10))
543 return nil
544 }
545 return nil
546}
547
548func (s *Session) handleRequestSlotsInfo(r *Request, d *Router) error {
549 var addr string

Callers 1

handleRequestMethod · 0.95

Calls 4

MakeSubRequestMethod · 0.80
IsIntMethod · 0.80
ErrorfMethod · 0.80
dispatchMethod · 0.45

Tested by

no test coverage detected