Documentation ¶
Overview ¶
This package provides an easy to use interface for creating and parsing messages encoded in the REdis Serialization Protocol (RESP). You can check out more details about the protocol here: http://redis.io/topics/protocol
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteArbitrary ¶
WriteArbitrary takes in any primitive golang value, or Message, and writes its encoded form to the given io.Writer, inferring types where appropriate.
func WriteArbitraryAsFlattenedStrings ¶ added in v0.4.2
WriteArbitraryAsFlattenedStrings is similar to WriteArbitrary except that it will encode all types except Array as a BulkStr, converting the argument into a string first as necessary. It will also flatten any embedded arrays into a single long array. This is useful because commands to a redis server must be given as an array of bulk strings. If the argument isn't already in a slice or map it will be wrapped so that it is written as an Array of size one.
Note that if a Message type is found it will *not* be encoded to a BulkStr, but will simply be passed through as whatever type it already represents.
func WriteArbitraryAsString ¶
WriteArbitraryAsString is similar to WriteArbitraryAsFlattenedString except that it won't flatten any embedded arrays.
Types ¶
type Message ¶
type Message struct { Type // contains filtered or unexported fields }
func NewMessage ¶
NewMessagePParses the given raw message and returns a Message struct representing it
func ReadMessage ¶
ReadMessage attempts to read a message object from the given io.Reader, parse it, and return a Message struct representing it
func (*Message) Array ¶
Array returns the Message slice encompassed by this Messsage, assuming the Message is of type Array
func (*Message) Bytes ¶
Bytes returns a byte slice representing the value of the Message. Only valid for a Message of type SimpleStr, Err, and BulkStr. Others will return an error
func (*Message) Err ¶
Err returns an error representing the value of the Message. Only valid for Err messages