proto

package
v9.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: BSD-2-Clause Imports: 13 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 DefaultBufferSize = 32 * 1024

DefaultBufferSize is the default size for read/write buffers (32 KiB).

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

Variables

This section is empty.

Functions

func IsAuthError added in v9.17.0

func IsAuthError(err error) bool

IsAuthError checks if an error is an AuthError, even if wrapped.

func IsClusterDownError added in v9.17.0

func IsClusterDownError(err error) bool

IsClusterDownError checks if an error is a ClusterDownError, even if wrapped.

func IsExecAbortError added in v9.17.0

func IsExecAbortError(err error) bool

IsExecAbortError checks if an error is an ExecAbortError, even if wrapped.

func IsLoadingError added in v9.17.0

func IsLoadingError(err error) bool

IsLoadingError checks if an error is a LoadingError, even if wrapped.

func IsMasterDownError added in v9.17.0

func IsMasterDownError(err error) bool

IsMasterDownError checks if an error is a MasterDownError, even if wrapped.

func IsMaxClientsError added in v9.17.0

func IsMaxClientsError(err error) bool

IsMaxClientsError checks if an error is a MaxClientsError, even if wrapped.

func IsNilReply

func IsNilReply(line []byte) bool

IsNilReply detects redis.Nil of RESP2.

func IsOOMError added in v9.17.0

func IsOOMError(err error) bool

IsOOMError checks if an error is an OOMError, even if wrapped.

func IsPermissionError added in v9.17.0

func IsPermissionError(err error) bool

IsPermissionError checks if an error is a PermissionError, even if wrapped.

func IsReadOnlyError added in v9.17.0

func IsReadOnlyError(err error) bool

IsReadOnlyError checks if an error is a ReadOnlyError, even if wrapped.

func IsTryAgainError added in v9.17.0

func IsTryAgainError(err error) bool

IsTryAgainError checks if an error is a TryAgainError, even if wrapped.

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 AskError added in v9.17.0

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

AskError is returned when a key is being migrated and the client should ask another node.

func IsAskError added in v9.17.0

func IsAskError(err error) (*AskError, bool)

IsAskError checks if an error is an AskError, even if wrapped. Returns the error and a boolean indicating if it's an AskError.

func NewAskError added in v9.17.0

func NewAskError(msg string, addr string) *AskError

NewAskError creates a new AskError with the given message and address.

func (*AskError) Addr added in v9.17.0

func (e *AskError) Addr() string

Addr returns the address of the node to ask.

func (*AskError) Error added in v9.17.0

func (e *AskError) Error() string

func (*AskError) RedisError added in v9.17.0

func (e *AskError) RedisError()

type AuthError added in v9.17.0

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

AuthError is returned when authentication fails.

func NewAuthError added in v9.17.0

func NewAuthError(msg string) *AuthError

NewAuthError creates a new AuthError with the given message.

func (*AuthError) Error added in v9.17.0

func (e *AuthError) Error() string

func (*AuthError) RedisError added in v9.17.0

func (e *AuthError) RedisError()

type ClusterDownError added in v9.17.0

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

ClusterDownError is returned when the cluster is down.

func NewClusterDownError added in v9.17.0

func NewClusterDownError(msg string) *ClusterDownError

NewClusterDownError creates a new ClusterDownError with the given message.

func (*ClusterDownError) Error added in v9.17.0

func (e *ClusterDownError) Error() string

func (*ClusterDownError) RedisError added in v9.17.0

func (e *ClusterDownError) RedisError()

type ExecAbortError added in v9.17.0

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

ExecAbortError is returned when a transaction is aborted.

func NewExecAbortError added in v9.17.0

func NewExecAbortError(msg string) *ExecAbortError

NewExecAbortError creates a new ExecAbortError with the given message.

func (*ExecAbortError) Error added in v9.17.0

func (e *ExecAbortError) Error() string

func (*ExecAbortError) RedisError added in v9.17.0

func (e *ExecAbortError) RedisError()

type LoadingError added in v9.17.0

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

LoadingError is returned when Redis is loading the dataset in memory.

func NewLoadingError added in v9.17.0

func NewLoadingError(msg string) *LoadingError

NewLoadingError creates a new LoadingError with the given message.

func (*LoadingError) Error added in v9.17.0

func (e *LoadingError) Error() string

func (*LoadingError) RedisError added in v9.17.0

func (e *LoadingError) RedisError()

type MasterDownError added in v9.17.0

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

MasterDownError is returned when the master is down.

func NewMasterDownError added in v9.17.0

func NewMasterDownError(msg string) *MasterDownError

NewMasterDownError creates a new MasterDownError with the given message.

func (*MasterDownError) Error added in v9.17.0

func (e *MasterDownError) Error() string

func (*MasterDownError) RedisError added in v9.17.0

func (e *MasterDownError) RedisError()

type MaxClientsError added in v9.17.0

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

MaxClientsError is returned when the maximum number of clients has been reached.

func NewMaxClientsError added in v9.17.0

func NewMaxClientsError(msg string) *MaxClientsError

NewMaxClientsError creates a new MaxClientsError with the given message.

func (*MaxClientsError) Error added in v9.17.0

func (e *MaxClientsError) Error() string

func (*MaxClientsError) RedisError added in v9.17.0

func (e *MaxClientsError) RedisError()

type MovedError added in v9.17.0

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

MovedError is returned when a key has been moved to a different node in a cluster.

func IsMovedError added in v9.17.0

func IsMovedError(err error) (*MovedError, bool)

IsMovedError checks if an error is a MovedError, even if wrapped. Returns the error and a boolean indicating if it's a MovedError.

func NewMovedError added in v9.17.0

func NewMovedError(msg string, addr string) *MovedError

NewMovedError creates a new MovedError with the given message and address.

func (*MovedError) Addr added in v9.17.0

func (e *MovedError) Addr() string

Addr returns the address of the node where the key has been moved.

func (*MovedError) Error added in v9.17.0

func (e *MovedError) Error() string

func (*MovedError) RedisError added in v9.17.0

func (e *MovedError) RedisError()

type OOMError added in v9.17.0

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

OOMError is returned when Redis is out of memory.

func NewOOMError added in v9.17.0

func NewOOMError(msg string) *OOMError

NewOOMError creates a new OOMError with the given message.

func (*OOMError) Error added in v9.17.0

func (e *OOMError) Error() string

func (*OOMError) RedisError added in v9.17.0

func (e *OOMError) RedisError()

type PermissionError added in v9.17.0

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

PermissionError is returned when a user lacks required permissions.

func NewPermissionError added in v9.17.0

func NewPermissionError(msg string) *PermissionError

NewPermissionError creates a new PermissionError with the given message.

func (*PermissionError) Error added in v9.17.0

func (e *PermissionError) Error() string

func (*PermissionError) RedisError added in v9.17.0

func (e *PermissionError) RedisError()

type ReadOnlyError added in v9.17.0

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

ReadOnlyError is returned when trying to write to a read-only replica.

func NewReadOnlyError added in v9.17.0

func NewReadOnlyError(msg string) *ReadOnlyError

NewReadOnlyError creates a new ReadOnlyError with the given message.

func (*ReadOnlyError) Error added in v9.17.0

func (e *ReadOnlyError) Error() string

func (*ReadOnlyError) RedisError added in v9.17.0

func (e *ReadOnlyError) RedisError()

type Reader

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

func NewReader

func NewReader(rd io.Reader) *Reader

func NewReaderSize added in v9.12.0

func NewReaderSize(rd io.Reader, size int) *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) PeekPushNotificationName added in v9.15.0

func (r *Reader) PeekPushNotificationName() (string, 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 TryAgainError added in v9.17.0

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

TryAgainError is returned when a command cannot be processed and should be retried.

func NewTryAgainError added in v9.17.0

func NewTryAgainError(msg string) *TryAgainError

NewTryAgainError creates a new TryAgainError with the given message.

func (*TryAgainError) Error added in v9.17.0

func (e *TryAgainError) Error() string

func (*TryAgainError) RedisError added in v9.17.0

func (e *TryAgainError) 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