当前位置: 首页>>代码示例>>Java>>正文


Java Protocol.read方法代码示例

本文整理汇总了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;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:ProtocolBenchmark.java

示例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;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:16,代码来源:ProtocolBenchmark.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:8,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:14,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:8,代码来源:ProtocolTest.java

示例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.");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:13,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:15,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:ProtocolTest.java

示例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);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:ProtocolTest.java


注:本文中的redis.clients.jedis.Protocol.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。