Class GridRedisProtocolParser


  • public class GridRedisProtocolParser
    extends Object
    Parser to decode/encode Redis protocol (RESP) requests.
    • Field Detail

      • ERROR_INT

        public static final int ERROR_INT
        Error while reading int. -1 used to mark null array.
        See Also:
        NIL, Constant Field Values
    • Constructor Detail

      • GridRedisProtocolParser

        public GridRedisProtocolParser()
    • Method Detail

      • toSimpleString

        public static ByteBuffer toSimpleString​(String val)
        Converts a simple string data to a ByteBuffer.
        Parameters:
        val - String to be converted to a simple string.
        Returns:
        Redis simple string.
      • toSimpleString

        public static ByteBuffer toSimpleString​(byte[] b)
        Creates a simple string data as a ByteBuffer.
        Parameters:
        b - Bytes for a simple string.
        Returns:
        Redis simple string.
      • oKString

        public static ByteBuffer oKString()
        Returns:
        Standard OK string.
      • toGenericError

        public static ByteBuffer toGenericError​(String errMsg)
        Creates a generic error response.
        Parameters:
        errMsg - Error message.
        Returns:
        Error response.
      • toTypeError

        public static ByteBuffer toTypeError​(String errMsg)
        Creates an error response on operation against the wrong data type.
        Parameters:
        errMsg - Error message.
        Returns:
        Error response.
      • toInteger

        public static ByteBuffer toInteger​(String integer)
        Converts an integer result to a RESP integer.
        Parameters:
        integer - Integer result.
        Returns:
        REDIS integer.
      • toInteger

        public static ByteBuffer toInteger​(int integer)
        Converts an integer result to a RESP integer.
        Parameters:
        integer - Integer result.
        Returns:
        REDIS integer.
      • nil

        public static ByteBuffer nil()
        Creates Nil response.
        Returns:
        Nil response.
      • toBulkString

        public static ByteBuffer toBulkString​(Object val)
        Converts a resultant object to a bulk string.
        Parameters:
        val - Object.
        Returns:
        Bulk string.
      • toArray

        public static ByteBuffer toArray​(Map<Object,​Object> vals)
        Converts a resultant map response to an array.
        Parameters:
        vals - Map.
        Returns:
        Array response.
      • toOrderedArray

        public static ByteBuffer toOrderedArray​(Map<Object,​Object> vals,
                                                List<?> origin)
        Converts a resultant map response to an array, the order of elements in the resulting array is defined by the order of elements in the origin collection.
        Parameters:
        vals - Map.
        origin - List that defines the order of the resulting array.
        Returns:
        Array response.
      • toArray

        public static ByteBuffer toArray​(Collection<Object> vals)
        Converts a resultant collection response to an array.
        Parameters:
        vals - Array elements.
        Returns:
        Array response.