Class RedisInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
redis.clients.jedis.util.RedisInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class RedisInputStream extends FilterInputStream
This class assumes (to some degree) that we are reading a RESP stream. As such it assumes certain conventions regarding CRLF line termination. It also assumes that if the Protocol layer requires a byte that if that byte is not there it is a stream error.
  • Field Details

    • INPUT_BUFFER_SIZE

      private static final int INPUT_BUFFER_SIZE
    • buf

      protected final byte[] buf
    • count

      protected int count
    • limit

      protected int limit
  • Constructor Details

    • RedisInputStream

      public RedisInputStream(InputStream in, int size)
    • RedisInputStream

      public RedisInputStream(InputStream in)
  • Method Details

    • readByte

      public byte readByte() throws JedisConnectionException
      Throws:
      JedisConnectionException
    • readLine

      public String readLine()
    • readLineBytes

      public byte[] readLineBytes()
    • readLineBytesSlowly

      private byte[] readLineBytesSlowly()
      Slow path in case a line of bytes cannot be read in one #fill() operation. This is still faster than creating the StrinbBuilder, String, then encoding as byte[] in Protocol, then decoding back into a String.
    • readIntCrLf

      public int readIntCrLf()
    • readLongCrLf

      public long readLongCrLf()
    • read

      public int read(byte[] b, int off, int len) throws JedisConnectionException
      Overrides:
      read in class FilterInputStream
      Throws:
      JedisConnectionException
    • ensureFill

      private void ensureFill() throws JedisConnectionException
      This methods assumes there are required bytes to be read. If we cannot read anymore bytes an exception is thrown to quickly ascertain that the stream was smaller than expected.
      Throws:
      JedisConnectionException