redis

package
v0.0.0-...-d3e924d Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBulkBytesLen = 1024 * 1024 * 512
	MaxArrayLen     = 1024 * 1024
)

Variables

View Source
var (
	ErrBadCRLFEnd = errors.New("bad CRLF end")

	ErrBadArrayLen        = errors.New("bad array len")
	ErrBadArrayLenTooLong = errors.New("bad array len, too long")

	ErrBadBulkBytesLen        = errors.New("bad bulk bytes len")
	ErrBadBulkBytesLenTooLong = errors.New("bad bulk bytes len, too long")

	ErrBadMultiBulkLen     = errors.New("bad multi-bulk len")
	ErrBadMultiBulkContent = errors.New("bad multi-bulk content, should be bulkbytes")
)
View Source
var ErrFailedDecoder = errors.New("use of failed decoder")
View Source
var ErrFailedEncoder = errors.New("use of failed encoder")

Functions

func Btoi64

func Btoi64(b []byte) (int64, error)

func Encode

func Encode(w io.Writer, r *Resp) error

func EncodeToBytes

func EncodeToBytes(r *Resp) ([]byte, error)

func IsTimeout

func IsTimeout(err error) bool

Types

type Conn

type Conn struct {
	Sock net.Conn

	*Decoder
	*Encoder

	ReaderTimeout time.Duration
	WriterTimeout time.Duration

	LastWrite time.Time
}

func DialTimeout

func DialTimeout(addr string, timeout time.Duration, rbuf, wbuf int) (*Conn, error)

func NewConn

func NewConn(sock net.Conn, rbuf, wbuf int) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) CloseReader

func (c *Conn) CloseReader() error

func (*Conn) FlushEncoder

func (c *Conn) FlushEncoder() *FlushEncoder

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() string

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() string

func (*Conn) SetKeepAlivePeriod

func (c *Conn) SetKeepAlivePeriod(d time.Duration) error

type Decoder

type Decoder struct {
	Err error
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func NewDecoderBuffer

func NewDecoderBuffer(br *bufio2.Reader) *Decoder

func NewDecoderSize

func NewDecoderSize(r io.Reader, size int) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (*Resp, error)

func (*Decoder) DecodeMultiBulk

func (d *Decoder) DecodeMultiBulk() ([]*Resp, error)

type Encoder

type Encoder struct {
	Err error
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func NewEncoderBuffer

func NewEncoderBuffer(bw *bufio2.Writer) *Encoder

func NewEncoderSize

func NewEncoderSize(w io.Writer, size int) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(r *Resp, flush bool) error

func (*Encoder) EncodeMultiBulk

func (e *Encoder) EncodeMultiBulk(multi []*Resp, flush bool) error

func (*Encoder) Flush

func (e *Encoder) Flush() error

type FlushEncoder

type FlushEncoder struct {
	Conn *Conn

	MaxInterval time.Duration
	MaxBuffered int
	// contains filtered or unexported fields
}

func (*FlushEncoder) Encode

func (p *FlushEncoder) Encode(resp *Resp) error

func (*FlushEncoder) EncodeMultiBulk

func (p *FlushEncoder) EncodeMultiBulk(multi []*Resp) error

func (*FlushEncoder) Flush

func (p *FlushEncoder) Flush(force bool) error

func (*FlushEncoder) NeedFlush

func (p *FlushEncoder) NeedFlush() bool

type Resp

type Resp struct {
	Type RespType

	Value []byte
	Array []*Resp
}

func Decode

func Decode(r io.Reader) (*Resp, error)

func DecodeFromBytes

func DecodeFromBytes(p []byte) (*Resp, error)

func DecodeMultiBulkFromBytes

func DecodeMultiBulkFromBytes(p []byte) ([]*Resp, error)

func NewArray

func NewArray(array []*Resp) *Resp

func NewBulkBytes

func NewBulkBytes(value []byte) *Resp

func NewError

func NewError(value []byte) *Resp

func NewErrorf

func NewErrorf(format string, args ...interface{}) *Resp

func NewInt

func NewInt(value []byte) *Resp

func NewString

func NewString(value []byte) *Resp

func (*Resp) IsArray

func (r *Resp) IsArray() bool

func (*Resp) IsBulkBytes

func (r *Resp) IsBulkBytes() bool

func (*Resp) IsError

func (r *Resp) IsError() bool

func (*Resp) IsInt

func (r *Resp) IsInt() bool

func (*Resp) IsString

func (r *Resp) IsString() bool

type RespType

type RespType byte
const (
	TypeString    RespType = '+'
	TypeError     RespType = '-'
	TypeInt       RespType = ':'
	TypeBulkBytes RespType = '$'
	TypeArray     RespType = '*'
)

func (RespType) String

func (t RespType) String() string

Jump to

Keyboard shortcuts

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