use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolBenchmark method measureInputStatus.
private static long measureInputStatus() throws Exception {
long duration = 0;
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
RedisInputStream in = new RedisInputStream(is);
for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
long start = System.nanoTime();
Protocol.read(in);
duration += (System.nanoTime() - start);
in.reset();
}
return duration;
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method singleLineReply.
@Test
public void singleLineReply() {
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
byte[] response = (byte[]) Protocol.read(new RedisInputStream(is));
assertArrayEquals(SafeEncoder.encode("OK"), response);
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method nullBulkReply.
@Test
public void nullBulkReply() {
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
String response = (String) Protocol.read(new RedisInputStream(is));
assertEquals(null, response);
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method bulkReply.
@Test
public void bulkReply() {
InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
byte[] response = (byte[]) Protocol.read(new RedisInputStream(is));
assertArrayEquals(SafeEncoder.encode("foobar"), response);
}
Aggregations