redis

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CR byte = '\r'
	LF byte = '\n'
)
View Source
const (
	ASKING      = "asking"
	MOVED       = "moved"
	ASK         = "ask"
	CLUSTERDOWN = "clusterdown"
)

Variables

View Source
var (
	// ErrBadRespType represents bad resp type
	ErrBadRespType = errors.New("bad resp type")

	// ErrBadCRLFEnd for invalid crlf
	ErrBadCRLFEnd = errors.New("bad CRLF end")

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

	// ErrBadBulkStringLen for invalid bulk string len
	ErrBadBulkStringLen = errors.New("bad bulk string len")
	// ErrBadBulkStringLenTooLong for too long bulk string len
	ErrBadBulkStringLenTooLong = errors.New("bad bulk string len, too long")

	// ErrBadMultiBulkLen for invalid multi-bulk len
	ErrBadMultiBulkLen = errors.New("bad multi-bulk len")
	// ErrBadMultiBulkContent for invalid multi-bulk content
	ErrBadMultiBulkContent = errors.New("bad multi-bulk content, should be bulkbytes")
)
View Source
var (
	ErrFilterNotFound = errors.New("error filter not found")
	ErrFilterIsNull   = errors.New("filter is null")
	ErrFilterExist    = errors.New("filter exist")
	ErrFilterNotExist = errors.New("filter not exist")
)
View Source
var CRLF = []byte{CR, LF}

crlf is the delimter in redis protocol.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	// cmd is always lowercase.
	Do(cmd string, req *simpleRequest) FilterStatus
	Destroy()
}

Filter is used to filter the request to backend.

type FilterChain

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

FilterChain is a set of filters

func (*FilterChain) AddFilter

func (c *FilterChain) AddFilter(f Filter)

AddFilter adds a filter

func (*FilterChain) Do

func (c *FilterChain) Do(r *simpleRequest) FilterStatus

Do call all filters in FilterChain

func (*FilterChain) Reset

func (c *FilterChain) Reset()

Reset clean and destroy all filters

type FilterStatus

type FilterStatus string

FilterStatus type

const (
	Continue FilterStatus = "Continue"
	Stop     FilterStatus = "Stop"
)

FilterStatus types

type Reader

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

Reader implements Reader for buffer

func NewReader

func NewReader(rd io.Reader) *Reader

NewReader creates Reader

func NewReaderSize

func NewReaderSize(rd io.Reader, size int) *Reader

NewReaderSize creates Reader with buffer size

func (*Reader) PeekByte

func (b *Reader) PeekByte() (byte, error)

PeekByte returns a single byte but does not consume

func (*Reader) Read

func (b *Reader) Read(p []byte) (int, error)

func (*Reader) ReadByte

func (b *Reader) ReadByte() (byte, error)

ReadByte reads a single byte

func (*Reader) ReadBytes

func (b *Reader) ReadBytes(delim byte) ([]byte, error)

ReadBytes reads bytes until a delimiter

func (*Reader) ReadFull

func (b *Reader) ReadFull(n int) ([]byte, error)

ReadFull reads n bytes

func (*Reader) ReadSlice

func (b *Reader) ReadSlice(delim byte) ([]byte, error)

ReadSlice reads a slice until a delimiter

type RespType

type RespType byte
const (
	SimpleString RespType = '+'
	Error        RespType = '-'
	Integer      RespType = ':'
	BulkString   RespType = '$'
	Array        RespType = '*'
)

type RespValue

type RespValue struct {
	Type RespType

	Int   int64
	Text  []byte
	Array []RespValue
}

func (*RespValue) Equal

func (r *RespValue) Equal(that *RespValue) bool

func (*RespValue) String

func (r *RespValue) String() string

Directories

Path Synopsis
Package compressor is a generated GoMock package.
Package compressor is a generated GoMock package.

Jump to

Keyboard shortcuts

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