Java Code Examples for redis.clients.jedis.Protocol#read()
The following examples show how to use
redis.clients.jedis.Protocol#read() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtocolBenchmark.java From cachecloud with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: ProtocolBenchmark.java From cachecloud with Apache License 2.0 | 5 votes |
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; }
Example 3
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void fragmentedBulkReply() { FragmentedByteArrayInputStream fis = new FragmentedByteArrayInputStream( "$30\r\n012345678901234567890123456789\r\n".getBytes()); byte[] response = (byte[]) Protocol.read(new RedisInputStream(fis)); assertArrayEquals(SafeEncoder.encode("012345678901234567890123456789"), response); }
Example 4
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void multiBulkReply() { InputStream is = new ByteArrayInputStream( "*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n".getBytes()); List<byte[]> response = (List<byte[]>) Protocol.read(new RedisInputStream(is)); List<byte[]> expected = new ArrayList<byte[]>(); expected.add(SafeEncoder.encode("foo")); expected.add(SafeEncoder.encode("bar")); expected.add(SafeEncoder.encode("Hello")); expected.add(SafeEncoder.encode("World")); assertEquals(expected, response); }
Example 5
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 4 votes |
@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); }
Example 7
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 4 votes |
@Test public void nullBulkReply() { InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes()); String response = (String) Protocol.read(new RedisInputStream(is)); assertEquals(null, response); }
Example 8
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 4 votes |
@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); }
Example 9
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 4 votes |
@Test public void integerReply() { InputStream is = new ByteArrayInputStream(":123\r\n".getBytes()); long response = (Long) Protocol.read(new RedisInputStream(is)); assertEquals(123, response); }