| 445 | } |
| 446 | |
| 447 | func (c *Client) touchFromAddr(addr net.Addr, keys []string, expiration int32) error { |
| 448 | return c.withAddrRw(addr, func(conn *conn) error { |
| 449 | rw := conn.rw |
| 450 | for _, key := range keys { |
| 451 | if _, err := fmt.Fprintf(rw, "touch %s %d\r\n", key, expiration); err != nil { |
| 452 | return err |
| 453 | } |
| 454 | if err := rw.Flush(); err != nil { |
| 455 | return err |
| 456 | } |
| 457 | line, err := rw.ReadSlice('\n') |
| 458 | if err != nil { |
| 459 | return err |
| 460 | } |
| 461 | switch { |
| 462 | case bytes.Equal(line, resultTouched): |
| 463 | break |
| 464 | case bytes.Equal(line, resultNotFound): |
| 465 | return ErrCacheMiss |
| 466 | default: |
| 467 | return fmt.Errorf("memcache: unexpected response line from touch: %q", string(line)) |
| 468 | } |
| 469 | } |
| 470 | return nil |
| 471 | }) |
| 472 | } |
| 473 | |
| 474 | // GetMulti is a batch version of Get. The returned map from keys to |
| 475 | // items may have fewer elements than the input slice, due to memcache |