TouchRequest extends AsciiRequest<MemcacheStatus> { @Override protected void handle(final AsciiResponse response, final HostAndPort server) throws IOException { AsciiResponse.Type type = response.type; if (type == AsciiResponse.Type.TOUCHED) { succeed(MemcacheStatus.OK); } else if (type == AsciiResponse.Type.NOT_FOUND) { succeed(MemcacheStatus.KEY_NOT_FOUND); } else { throw new IOException("Unexpected line: " + type); } } TouchRequest(byte[] key, int ttl); @Override ByteBuf writeRequest(ByteBufAllocator alloc, ByteBuffer dst);  }
@Test public void testResponse() throws IOException, InterruptedException, ExecutionException { req.handle(AsciiResponse.TOUCHED, HostAndPort.fromHost("host")); assertEquals(MemcacheStatus.OK, req.get()); }
@Test public void testNonFoundResponse() throws IOException, InterruptedException, ExecutionException { req.handle(AsciiResponse.NOT_FOUND, HostAndPort.fromHost("host")); assertEquals(MemcacheStatus.KEY_NOT_FOUND, req.get()); }