本文整理汇总了Java中redis.clients.jedis.Protocol.read方法的典型用法代码示例。如果您正苦于以下问题:Java Protocol.read方法的具体用法?Java Protocol.read怎么用?Java Protocol.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Protocol
的用法示例。
在下文中一共展示了Protocol.read方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: measureInputMulti
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
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;
}
示例2: measureInputStatus
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
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;
}
示例3: fragmentedBulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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);
}
示例4: multiBulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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"));
assertByteArrayListEquals(expected, response);
}
示例5: nullMultiBulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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);
}
示例6: busyReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@Test
public void busyReply() {
final String busyMessage = "BUSY Redis is busy running a script.";
final InputStream is = new ByteArrayInputStream(('-' + busyMessage + "\r\n").getBytes());
try {
Protocol.read(new RedisInputStream(is));
} catch (final JedisBusyException e) {
assertEquals(busyMessage, e.getMessage());
return;
}
fail("Expected a JedisBusyException to be thrown.");
}
示例7: multiBulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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);
}
示例8: bulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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);
}
示例9: nullBulkReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@Test
public void nullBulkReply() {
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
String response = (String) Protocol.read(new RedisInputStream(is));
assertEquals(null, response);
}
示例10: singleLineReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@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);
}
示例11: integerReply
import redis.clients.jedis.Protocol; //导入方法依赖的package包/类
@Test
public void integerReply() {
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
long response = (Long) Protocol.read(new RedisInputStream(is));
assertEquals(123, response);
}