Search in sources :

Example 11 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

the class ProtocolBenchmark method measureInputMulti.

private static long measureInputMulti() throws Exception {
    long duration = 0;
    InputStream is = new ByteArrayInputStream("*4\r\n$3\r\nfoo\r\n$13\r\nbarbarbarfooz\r\n$5\r\nHello\r\n$5\r\nWorld\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 12 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

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)

Example 13 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

the class ProtocolTest method nullMultiBulkReply.

@SuppressWarnings("unchecked")
@Test
public void nullMultiBulkReply() {
    InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
    List<String> response = (List<String>) Protocol.read(new RedisInputStream(is));
    assertNull(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) ArrayList(java.util.ArrayList) List(java.util.List) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 14 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

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 15 with RedisInputStream

use of redis.clients.util.RedisInputStream in project jedis by xetorthio.

the class ProtocolBenchmark method measureInputMulti.

private static long measureInputMulti() throws Exception {
    long duration = 0;
    InputStream is = new ByteArrayInputStream("*4\r\n$3\r\nfoo\r\n$13\r\nbarbarbarfooz\r\n$5\r\nHello\r\n$5\r\nWorld\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)

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