ping sends the version command to the given addr
(addr net.Addr)
| 421 | |
| 422 | // ping sends the version command to the given addr |
| 423 | func (c *Client) ping(addr net.Addr) error { |
| 424 | return c.withAddrRw(addr, func(conn *conn) error { |
| 425 | rw := conn.rw |
| 426 | if _, err := fmt.Fprintf(rw, "version\r\n"); err != nil { |
| 427 | return err |
| 428 | } |
| 429 | if err := rw.Flush(); err != nil { |
| 430 | return err |
| 431 | } |
| 432 | line, err := rw.ReadSlice('\n') |
| 433 | if err != nil { |
| 434 | return err |
| 435 | } |
| 436 | |
| 437 | switch { |
| 438 | case bytes.HasPrefix(line, versionPrefix): |
| 439 | break |
| 440 | default: |
| 441 | return fmt.Errorf("memcache: unexpected response line from ping: %q", string(line)) |
| 442 | } |
| 443 | return nil |
| 444 | }) |
| 445 | } |
| 446 | |
| 447 | func (c *Client) touchFromAddr(addr net.Addr, keys []string, expiration int32) error { |
| 448 | return c.withAddrRw(addr, func(conn *conn) error { |
nothing calls this directly
no test coverage detected