redis resp protocol data type.
const (
RespStatus = '+' // +<string>\r\n
RespError = '-' // -<string>\r\n
RespString = '$' // $<length>\r\n<bytes>\r\n
RespInt = ':' // :<number>\r\n
RespNil = '_' // _\r\n
RespFloat = ',' // ,<floating-point-number>\r\n (golang float)
RespBool = '#' // true: #t\r\n false: #f\r\n
RespBlobError = '!' // !<length>\r\n<bytes>\r\n
RespVerbatim = '=' // =<length>\r\nFORMAT:<bytes>\r\n
RespBigInt = '(' // (<big number>\r\n
RespArray = '*' // *<len>\r\n... (same as resp2)
RespMap = '%' // %<len>\r\n(key)\r\n(value)\r\n... (golang map)
RespSet = '~' // ~<len>\r\n... (same as Array)
RespAttr = '|' // |<len>\r\n(key)\r\n(value)\r\n... + command reply
RespPush = '>' // ><len>\r\n... (same as Array)
)
DefaultBufferSize is the default size for read/write buffers (32 KiB).
const DefaultBufferSize = 32 * 1024
const Nil = RedisError("redis: nil") // nolint:errname
func IsNilReply(line []byte) bool
IsNilReply detects redis.Nil of RESP2.
func ParseErrorReply(line []byte) error
func Scan(b []byte, v interface{}) error
Scan parses bytes `b` to `v` with appropriate type.
func ScanSlice(data []string, slice interface{}) error
type Reader struct {
// contains filtered or unexported fields
}
func NewReader(rd io.Reader) *Reader
func NewReaderSize(rd io.Reader, size int) *Reader
func (r *Reader) Buffered() int
func (r *Reader) Discard(line []byte) (err error)
Discard the data represented by line.
func (r *Reader) DiscardNext() error
DiscardNext read and discard the data represented by the next line.
func (r *Reader) Peek(n int) ([]byte, error)
func (r *Reader) PeekReplyType() (byte, error)
PeekReplyType returns the data type of the next response without advancing the Reader, and discard the attribute type.
func (r *Reader) ReadArrayLen() (int, error)
ReadArrayLen Read and return the length of the array.
func (r *Reader) ReadBool() (bool, error)
func (r *Reader) ReadFixedArrayLen(fixedLen int) error
ReadFixedArrayLen read fixed array length.
func (r *Reader) ReadFixedMapLen(fixedLen int) error
ReadFixedMapLen reads fixed map length.
func (r *Reader) ReadFloat() (float64, error)
func (r *Reader) ReadInt() (int64, error)
func (r *Reader) ReadLine() ([]byte, error)
ReadLine Return a valid reply, it will check the protocol or redis error, and discard the attribute type.
func (r *Reader) ReadMapLen() (int, error)
ReadMapLen reads the length of the map type. If responding to the array type (RespArray/RespSet/RespPush), it must be a multiple of 2 and return n/2. Other types will return an error.
func (r *Reader) ReadReply() (interface{}, error)
func (r *Reader) ReadSlice() ([]interface{}, error)
func (r *Reader) ReadString() (string, error)
func (r *Reader) ReadUint() (uint64, error)
func (r *Reader) Reset(rd io.Reader)
type RedisError string
func (e RedisError) Error() string
func (RedisError) RedisError()
type Writer struct {
// contains filtered or unexported fields
}
func NewWriter(wr writer) *Writer
func (w *Writer) WriteArg(v interface{}) error
func (w *Writer) WriteArgs(args []interface{}) error