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

Method handleRequestMSet

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

Source from the content-addressed store, hash-verified

425}
426
427func (s *Session) handleRequestMSet(r *Request, d *Router) error {
428 var nblks = len(r.Multi) - 1
429 switch {
430 case nblks == 0 || nblks%2 != 0:
431 r.Resp = redis.NewErrorf("ERR wrong number of arguments for 'MSET' command")
432 return nil
433 case nblks == 2:
434 return d.dispatch(r)
435 }
436 var sub = r.MakeSubRequest(nblks / 2)
437 for i := range sub {
438 sub[i].Multi = []*redis.Resp{
439 r.Multi[0],
440 r.Multi[i*2+1],
441 r.Multi[i*2+2],
442 }
443 if err := d.dispatch(&sub[i]); err != nil {
444 return err
445 }
446 }
447 r.Coalesce = func() error {
448 for i := range sub {
449 if err := sub[i].Err; err != nil {
450 return err
451 }
452 switch resp := sub[i].Resp; {
453 case resp == nil:
454 return ErrRespIsRequired
455 case resp.IsString():
456 r.Resp = resp
457 default:
458 return fmt.Errorf("bad mset resp: %s value.len = %d", resp.Type, len(resp.Value))
459 }
460 }
461 return nil
462 }
463 return nil
464}
465
466func (s *Session) handleRequestDel(r *Request, d *Router) error {
467 var nkeys = len(r.Multi) - 1

Callers 1

handleRequestMethod · 0.95

Calls 4

MakeSubRequestMethod · 0.80
IsStringMethod · 0.80
ErrorfMethod · 0.80
dispatchMethod · 0.45

Tested by

no test coverage detected