proto

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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)
)

redis resp protocol data type.

View Source
const Nil = RedisError("redis: nil") // nolint:errname

Variables

This section is empty.

Functions

func IsNilReply

func IsNilReply(line []byte) bool

IsNilReply detects redis.Nil of RESP2.

func ParseErrorReply

func ParseErrorReply(line []byte) error

func Scan

func Scan(b []byte, v interface{}) error

Scan parses bytes `b` to `v` with appropriate type.

func ScanSlice

func ScanSlice(data []string, slice interface{}) error

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(rd io.Reader) *Reader

func (*Reader) Buffered

func (r *Reader) Buffered() int

func (*Reader) Discard

func (r *Reader) Discard(line []byte) (err error)

Discard the data represented by line.

func (*Reader) DiscardNext

func (r *Reader) DiscardNext() error

DiscardNext read and discard the data represented by the next line.

func (*Reader) Peek

func (r *Reader) Peek(n int) ([]byte, error)

func (*Reader) PeekReplyType

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 (*Reader) ReadArrayLen

func (r *Reader) ReadArrayLen() (int, error)

ReadArrayLen Read and return the length of the array.

func (*Reader) ReadBool

func (r *Reader) ReadBool() (bool, error)

func (*Reader) ReadFixedArrayLen

func (r *Reader) ReadFixedArrayLen(fixedLen int) error

ReadFixedArrayLen read fixed array length.

func (*Reader) ReadFixedMapLen

func (r *Reader) ReadFixedMapLen(fixedLen int) error

ReadFixedMapLen reads fixed map length.

func (*Reader) ReadFloat

func (r *Reader) ReadFloat() (float64, error)

func (*Reader) ReadInt

func (r *Reader) ReadInt() (int64, error)

func (*Reader) ReadLine

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 (*Reader) ReadMapLen

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 (*Reader) ReadReply

func (r *Reader) ReadReply() (interface{}, error)

func (*Reader) ReadSlice

func (r *Reader) ReadSlice() ([]interface{}, error)

func (*Reader) ReadString

func (r *Reader) ReadString() (string, error)

func (*Reader) ReadUint

func (r *Reader) ReadUint() (uint64, error)

func (*Reader) Reset

func (r *Reader) Reset(rd io.Reader)

type RedisError

type RedisError string

func (RedisError) Error

func (e RedisError) Error() string

func (RedisError) RedisError

func (RedisError) RedisError()

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(wr writer) *Writer

func (*Writer) WriteArg

func (w *Writer) WriteArg(v interface{}) error

func (*Writer) WriteArgs

func (w *Writer) WriteArgs(args []interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL