Documentation
¶
Index ¶
- Constants
- func IsAuthError(err error) bool
- func IsClusterDownError(err error) bool
- func IsExecAbortError(err error) bool
- func IsLoadingError(err error) bool
- func IsMasterDownError(err error) bool
- func IsMaxClientsError(err error) bool
- func IsNilReply(line []byte) bool
- func IsOOMError(err error) bool
- func IsPermissionError(err error) bool
- func IsReadOnlyError(err error) bool
- func IsTryAgainError(err error) bool
- func ParseErrorReply(line []byte) error
- func Scan(b []byte, v interface{}) error
- func ScanSlice(data []string, slice interface{}) error
- type AskError
- type AuthError
- type ClusterDownError
- type ExecAbortError
- type LoadingError
- type MasterDownError
- type MaxClientsError
- type MovedError
- type OOMError
- type PermissionError
- type ReadOnlyError
- type Reader
- func (r *Reader) Buffered() int
- func (r *Reader) Discard(line []byte) (err error)
- func (r *Reader) DiscardNext() error
- func (r *Reader) Peek(n int) ([]byte, error)
- func (r *Reader) PeekPushNotificationName() (string, error)
- func (r *Reader) PeekReplyType() (byte, error)
- func (r *Reader) ReadArrayLen() (int, error)
- func (r *Reader) ReadBool() (bool, error)
- func (r *Reader) ReadFixedArrayLen(fixedLen int) error
- func (r *Reader) ReadFixedMapLen(fixedLen int) error
- func (r *Reader) ReadFloat() (float64, error)
- func (r *Reader) ReadInt() (int64, error)
- func (r *Reader) ReadLine() ([]byte, error)
- func (r *Reader) ReadMapLen() (int, 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
- type TryAgainError
- type Writer
Constants ¶
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.
const DefaultBufferSize = 32 * 1024
DefaultBufferSize is the default size for read/write buffers (32 KiB).
const Nil = RedisError("redis: nil") // nolint:errname
Variables ¶
This section is empty.
Functions ¶
func IsAuthError ¶ added in v9.17.0
IsAuthError checks if an error is an AuthError, even if wrapped.
func IsClusterDownError ¶ added in v9.17.0
IsClusterDownError checks if an error is a ClusterDownError, even if wrapped.
func IsExecAbortError ¶ added in v9.17.0
IsExecAbortError checks if an error is an ExecAbortError, even if wrapped.
func IsLoadingError ¶ added in v9.17.0
IsLoadingError checks if an error is a LoadingError, even if wrapped.
func IsMasterDownError ¶ added in v9.17.0
IsMasterDownError checks if an error is a MasterDownError, even if wrapped.
func IsMaxClientsError ¶ added in v9.17.0
IsMaxClientsError checks if an error is a MaxClientsError, even if wrapped.
func IsOOMError ¶ added in v9.17.0
IsOOMError checks if an error is an OOMError, even if wrapped.
func IsPermissionError ¶ added in v9.17.0
IsPermissionError checks if an error is a PermissionError, even if wrapped.
func IsReadOnlyError ¶ added in v9.17.0
IsReadOnlyError checks if an error is a ReadOnlyError, even if wrapped.
func IsTryAgainError ¶ added in v9.17.0
IsTryAgainError checks if an error is a TryAgainError, even if wrapped.
func ParseErrorReply ¶
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
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
NewAskError creates a new AskError with the given message and address.
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
NewAuthError creates a new AuthError with the given message.
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
NewOOMError creates a new OOMError with the given message.
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 (*Reader) DiscardNext ¶
DiscardNext read and discard the data represented by the next line.
func (*Reader) PeekPushNotificationName ¶ added in v9.15.0
func (*Reader) PeekReplyType ¶
PeekReplyType returns the data type of the next response without advancing the Reader, and discard the attribute type.
func (*Reader) ReadArrayLen ¶
ReadArrayLen Read and return the length of the array.
func (*Reader) ReadFixedArrayLen ¶
ReadFixedArrayLen read fixed array length.
func (*Reader) ReadFixedMapLen ¶
ReadFixedMapLen reads fixed map length.
func (*Reader) ReadLine ¶
ReadLine Return a valid reply, it will check the protocol or redis error, and discard the attribute type.
func (*Reader) ReadMapLen ¶
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) ReadString ¶
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()