Class RESPWriter

java.lang.Object
com.blackrook.redis.io.RESPWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class RESPWriter extends Object implements Closeable
Writer class for writing requests to a Redis Socket.
Author:
Matthew Tropiano
  • Constructor Details

    • RESPWriter

      public RESPWriter(OutputStream out)
      Opens a RedisWriter attached to an output stream.
      Parameters:
      out - the OutputStream to use.
    • RESPWriter

      public RESPWriter(Writer out)
      Opens a RedisWriter attached to a writer.
      Parameters:
      out - the Writer to use.
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • writeNull

      public void writeNull()
      Writes a null object.
    • writeNullArray

      public void writeNullArray()
      Writes a null object.
    • writeNumber

      public void writeNumber(Number n)
      Writes a number to output.
      Parameters:
      n - the number to write.
    • writeSimpleString

      public void writeSimpleString(String s)
      Writes a simple string to output.
      Parameters:
      s - the string to write.
    • writeBulkString

      public void writeBulkString(String s)
      Writes a bulk string to output.
      Parameters:
      s - the string to write.
    • writeArray

      public void writeArray(Iterable<Object> iterable)
      Writes a bulk string array.
      Parameters:
      iterable - the objects to write.
    • writeArray

      public void writeArray(Object... objects)
      Writes a bulk string array.
      Parameters:
      objects - the objects to write.
    • writeArray

      public void writeArray(String... strings)
      Writes a bulk string array.
      Parameters:
      strings - the series of strings.
    • writeObject

      public void writeObject(RedisObject object)
      Writes a full object that represents a Redis request.
      Parameters:
      object - the Redis object to write.
    • writeChar

      public void writeChar(char c)
      Writes a character to output.
      Parameters:
      c - the character.
    • writeError

      public void writeError(String s)
      Writes an error to output.
      Parameters:
      s - the error string to write.
    • writeCommand

      public void writeCommand(String commandString)
      Writes a Redis command as though it will be executed from a REPL-like command prompt. The full command is sent to the server as a raw request.
      Parameters:
      commandString - the command to send to the server.
    • writeRaw

      public void writeRaw(String rawcontent)
      Writes raw content into this writer and flushes it.
      Parameters:
      rawcontent - the content to send.
    • writeNull

      protected void writeNull(boolean flush)
      Writes a null object.
      Parameters:
      flush - if true, flushes the stream.
    • writeNumber

      protected void writeNumber(Number n, boolean flush)
      Writes a number to output.
      Parameters:
      n - the number to write.
      flush - if true, flushes the stream.
    • writeSimpleString

      protected void writeSimpleString(String s, boolean flush)
      Writes a bulk string to output.
      Parameters:
      s - the string to write.
      flush - if true, flushes the stream.
    • writeBulkString

      protected void writeBulkString(String s, boolean flush)
      Writes a bulk string.
      Parameters:
      s - the string to write.
      flush - if true, flushes the stream.