Package redis.netty

Examples of redis.netty.RedisDecoder


          poll.setException(e.getCause());
        }
      }
    };
    final RedisEncoder encoder = new RedisEncoder();
    final RedisDecoder decoder = new RedisDecoder();
    cb.setPipelineFactory(new ChannelPipelineFactory() {
      @Override
      public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("redisEncoder", encoder);
View Full Code Here


public class ReplyTest {
  @Test
  public void testReadWrite() throws IOException {
    ChannelBuffer os;
    Reply receive;
    RedisDecoder redisDecoder = new RedisDecoder();
    {
      os = ChannelBuffers.dynamicBuffer();
      String message = "OK";
      new StatusReply(message).write(os);
      receive = redisDecoder.receive(os);
      assertTrue(receive instanceof StatusReply);
      assertEquals(message, receive.data());
    }
    {
      os = ChannelBuffers.dynamicBuffer();
      String message = "OK";
      new ErrorReply(message).write(os);
      receive = redisDecoder.receive(os);
      assertTrue(receive instanceof ErrorReply);
      assertEquals(message, receive.data());
    }
    {
      os = ChannelBuffers.dynamicBuffer();
      String message = "OK";
      new BulkReply(ChannelBuffers.wrappedBuffer(message.getBytes())).write(os);
      receive = redisDecoder.receive(os);
      assertTrue(receive instanceof BulkReply);
      assertEquals(message, ((ChannelBuffer)receive.data()).toString(Charsets.US_ASCII));
    }
    {
      os = ChannelBuffers.dynamicBuffer();
      long integer = 999;
      new IntegerReply(integer).write(os);
      receive = redisDecoder.receive(os);
      assertTrue(receive instanceof IntegerReply);
      assertEquals(integer, receive.data());
    }
    {
      os = ChannelBuffers.dynamicBuffer();
      String message = "OK";
      long integer = 999;
      new MultiBulkReply(new Reply[] {
              new StatusReply(message),
              new ErrorReply(message),
              new MultiBulkReply(new Reply[] { new StatusReply(message)}),
              new BulkReply(ChannelBuffers.wrappedBuffer(message.getBytes())),
              new IntegerReply(integer)}).write(os);
      receive = redisDecoder.receive(os);
      assertTrue(receive instanceof MultiBulkReply);
      Reply[] data = (Reply[]) receive.data();
      assertEquals(message, data[0].data());
      assertEquals(message, data[1].data());
      assertTrue(data[2] instanceof MultiBulkReply);
View Full Code Here

      baos.write("6\r\n".getBytes());
      baos.write("foobar\r\n".getBytes());
    }
    byte[] multiBulkReply = baos.toByteArray();
    long start = System.currentTimeMillis();
    RedisDecoder redisDecoder = new RedisDecoder();
    ChannelBuffer cb = ChannelBuffers.wrappedBuffer(multiBulkReply);
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 100000; j++) {
        Reply receive = redisDecoder.receive(cb);
        cb.resetReaderIndex();
      }
      long end = System.currentTimeMillis();
      long diff = end - start;
      System.out.println(diff + " " + ((double)diff)/100000);
View Full Code Here

TOP

Related Classes of redis.netty.RedisDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.