| 501 | } |
| 502 | |
| 503 | func (us UnitSlice) Mget(c *Conn) { |
| 504 | keys := make([]interface{}, len(us)) |
| 505 | for i := 0; i < len(us); i++ { |
| 506 | keys[i] = us[i].key |
| 507 | } |
| 508 | var rsp interface{} |
| 509 | defer func() { |
| 510 | if x := recover(); x != nil { |
| 511 | Panic("mget: c = %s, keys = %v, error = '%s', rsp = %v", c.Addr(), keys, x, rsp) |
| 512 | } |
| 513 | }() |
| 514 | var err error |
| 515 | if rsp, err = c.Do("mget", keys...); err != nil { |
| 516 | panic(err) |
| 517 | } |
| 518 | as := c.Values(rsp, len(us)) |
| 519 | for i := 0; i < len(us); i++ { |
| 520 | u := us[i] |
| 521 | switch u.val.(type) { |
| 522 | default: |
| 523 | panic(fmt.Sprintf("key = %s, invalid type", u.key)) |
| 524 | case int: |
| 525 | v := c.Int(as[i]) |
| 526 | if x := u.val.(int); x != v { |
| 527 | panic(fmt.Sprintf("key = %s, return = %d, expect = %d", u.key, v, x)) |
| 528 | } |
| 529 | case string: |
| 530 | v := c.String(as[i]) |
| 531 | if x := u.val.(string); x != v { |
| 532 | panic(fmt.Sprintf("key = %s, return = %s, expect = %s", u.key, v, x)) |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | func (us UnitSlice) Mset(c *Conn, vals ...interface{}) { |
| 539 | if len(us) != len(vals) { |