Search in sources :

Example 16 with RedisInputStream

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream)

Example 17 with RedisInputStream

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 18 with RedisInputStream

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 19 with RedisInputStream

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Aggregations

RedisInputStream (redis.clients.util.RedisInputStream)19 ByteArrayInputStream (java.io.ByteArrayInputStream)17 InputStream (java.io.InputStream)17 BufferedInputStream (java.io.BufferedInputStream)13 PipedInputStream (java.io.PipedInputStream)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)4 List (java.util.List)4 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Socket (java.net.Socket)2 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)2 RedisOutputStream (redis.clients.util.RedisOutputStream)2 SSLSocket (javax.net.ssl.SSLSocket)1 JedisBusyException (redis.clients.jedis.exceptions.JedisBusyException)1