Documentation
¶
Index ¶
- Constants
- Variables
- func NewErrNotSupported(target string) error
- type Arguments
- type AuthCommandHandler
- type Config
- type Conn
- func (conn *Conn) Database() DatabaseID
- func (conn *Conn) IsAuthrized() bool
- func (conn *Conn) SetAuthrized(authrized bool)
- func (conn *Conn) SetDatabase(id DatabaseID)
- func (conn *Conn) SetSpanContext(span tracer.Context)
- func (conn *Conn) SpanContext() tracer.Context
- func (conn *Conn) Timestamp() time.Time
- type ConnectionManagementCommandHandler
- type DatabaseID
- type Executor
- type Executors
- type ExpireOption
- type GenericCommandHandler
- type HSetOption
- type HashCommandHandler
- type ListCommandHandler
- type Message
- func NewArrayMessage() *Message
- func NewArrayMessageWithArray(val *proto.Array) *Message
- func NewBulkMessage(msg string) *Message
- func NewErrorMessage(err error) *Message
- func NewErrorNotSupportedMessage(cmd string) *Message
- func NewFloatMessage(val float64) *Message
- func NewIntegerMessage(val int) *Message
- func NewNilMessage() *Message
- func NewOKMessage() *Message
- func NewStringArrayMessage(strs []string) *Message
- func NewStringMessage(msg string) *Message
- type PushOption
- type RenameOption
- type ScanOption
- type ScanType
- type Server
- func (server *Server) Auth(conn *Conn, username string, password string) (*Message, error)
- func (server *Server) ConfigGet(conn *Conn, keys []string) (*Message, error)
- func (server *Server) ConfigSet(conn *Conn, params map[string]string) (*Message, error)
- func (server *Server) Echo(conn *Conn, arg string) (*Message, error)
- func (server *Server) Ping(conn *Conn, arg string) (*Message, error)
- func (server *Server) Quit(conn *Conn) (*Message, error)
- func (server *Server) RegisterExexutor(cmd string, executor Executor)
- func (server *Server) Restart() error
- func (server *Server) Select(conn *Conn, index int) (*Message, error)
- func (server *Server) SetAuthCommandHandler(handler AuthCommandHandler)
- func (server *Server) SetCommandHandler(handler UserCommandHandler)
- func (server *Server) SetTracer(t tracer.Tracer)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- type ServerConfig
- type ServerManagementCommandHandler
- type SetCommandHandler
- type SetOption
- type StringCommandHandler
- type SystemCommandHandler
- type UserCommandHandler
- type ZAddOption
- type ZRangeOption
- type ZSetCommandHandler
- type ZSetMember
Constants ¶
const ( // PackageName is the package name. PackageName = "go-redis" // LocalHost is the local host name. LocalHost = "localhost" // DefaultPort is the default port number. DefaultPort = 6379 // DefaultScanCount is the default scan count. DefaultScanCount = 10 // DefaultScanPattern is the default scan pattern. DefaultScanPattern = "*" // DefaultScanType is the default scan type. DefaultScanType = KeyScan )
const (
ConfigSep = " "
)
const (
OK = "OK"
)
const (
Version = "v1.4.4"
)
Variables ¶
Functions ¶
func NewErrNotSupported ¶ added in v1.4.0
NewErrNotSupported returns a new ErrNotSupported.
Types ¶
type AuthCommandHandler ¶ added in v1.4.0
type AuthCommandHandler interface {
Auth(conn *Conn, username string, password string) (*Message, error)
}
AuthCommandHandler represents a hander interface for authentication commands.
type Config ¶ added in v1.2.0
type Config struct {
// contains filtered or unexported fields
}
Config represents a server configuration.
func (*Config) AppendConfig ¶ added in v1.2.0
AppendConfig appends a specified parameter.
func (*Config) ConfigParameter ¶ added in v1.2.0
ConfigParameter return the specified parameter.
func (*Config) RemoveConfig ¶ added in v1.4.0
RemoveConfig removes the specified parameter.
type Conn ¶ added in v1.3.0
Conn represents a database connection.
func (*Conn) Database ¶ added in v1.3.0
func (conn *Conn) Database() DatabaseID
Database returns the current selected database number in the connection.
func (*Conn) IsAuthrized ¶ added in v1.4.0
IsAuthrized returns true if the connection is authrized.
func (*Conn) SetAuthrized ¶ added in v1.4.0
SetAuthrized sets the authrized flag to the connection.
func (*Conn) SetDatabase ¶ added in v1.3.0
func (conn *Conn) SetDatabase(id DatabaseID)
SetDatabase sets the selected database number to the connection.
func (*Conn) SetSpanContext ¶ added in v1.3.5
SetAuthrizedxt to the connection.
func (*Conn) SpanContext ¶ added in v1.3.5
SpanContext returns the span context of the connection.
type ConnectionManagementCommandHandler ¶ added in v1.2.0
type ConnectionManagementCommandHandler interface { Ping(conn *Conn, arg string) (*Message, error) Echo(conn *Conn, arg string) (*Message, error) Select(conn *Conn, index int) (*Message, error) Quit(conn *Conn) (*Message, error) }
ConnectionManagementCommandHandler represents a hander interface for connection management commands.
type ExpireOption ¶ added in v1.0.0
type GenericCommandHandler ¶ added in v1.0.0
type GenericCommandHandler interface { Del(conn *Conn, keys []string) (*Message, error) Exists(conn *Conn, keys []string) (*Message, error) Expire(conn *Conn, key string, opt ExpireOption) (*Message, error) Keys(conn *Conn, pattern string) (*Message, error) Rename(conn *Conn, key string, newkey string, opt RenameOption) (*Message, error) Type(conn *Conn, key string) (*Message, error) TTL(conn *Conn, key string) (*Message, error) Scan(conn *Conn, cursor int, opt ScanOption) (*Message, error) }
GenericCommandHandler represents a hander interface for genelic commands.
type HSetOption ¶ added in v1.0.0
type HSetOption struct {
NX bool
}
type HashCommandHandler ¶ added in v1.0.0
type HashCommandHandler interface { // HDel represents a handler interface for HDEL command. HDel(conn *Conn, key string, fields []string) (*Message, error) // HSet represents a handler interface for HSET and HSETNX commands. HSet(conn *Conn, key string, field string, val string, opt HSetOption) (*Message, error) // HGet represents a handler interface for HGET command. HGet(conn *Conn, key string, field string) (*Message, error) // HGetAll represents a handler interface for HGETALL command. HGetAll(conn *Conn, key string) (*Message, error) }
HashCommandHandler represents a core command hander interface for hash commands. HMSET and HMGET commands are implemented by the HashCommandHandler.
type ListCommandHandler ¶ added in v1.1.0
type ListCommandHandler interface { LPush(conn *Conn, key string, elements []string, opt PushOption) (*Message, error) RPush(conn *Conn, key string, elements []string, opt PushOption) (*Message, error) LPop(conn *Conn, key string, count int) (*Message, error) RPop(conn *Conn, key string, count int) (*Message, error) LRange(conn *Conn, key string, start int, stop int) (*Message, error) LIndex(conn *Conn, key string, index int) (*Message, error) LLen(conn *Conn, key string) (*Message, error) }
ListCommandHandler represents a core command hander interface for list commands.
type Message ¶
Message represents a message of Redis serialization protocol.
func NewArrayMessage ¶ added in v1.0.0
func NewArrayMessage() *Message
NewArrayMessage creates an empty array message.
func NewArrayMessageWithArray ¶ added in v1.1.0
NewArrayMessageWithArray creates an array message with the specified array.
func NewBulkMessage ¶
NewBulkMessage creates a bulk string message.
func NewErrorMessage ¶
NewErrorMessage creates an error message.
func NewErrorNotSupportedMessage ¶ added in v1.4.0
NewErrorNotSupportedMessage returns a new ErrNotSupported message.
func NewFloatMessage ¶ added in v1.1.0
NewFloatMessage creates an float message.
func NewIntegerMessage ¶
NewIntegerMessage creates an integer message.
func NewStringArrayMessage ¶ added in v1.0.0
NewStringArrayMessage creates an array message with the specified strings.
func NewStringMessage ¶
NewStringMessage creates a string message.
type PushOption ¶ added in v1.1.0
type PushOption struct {
X bool
}
type RenameOption ¶ added in v1.0.0
type RenameOption struct {
NX bool
}
type ScanOption ¶ added in v1.4.3
type Server ¶
type Server struct { *ServerConfig tracer.Tracer Addr string // contains filtered or unexported fields }
Server is an instance for Redis protocols.
func (*Server) RegisterExexutor ¶ added in v1.0.0
RegisterExexutor sets a command executor.
func (*Server) SetAuthCommandHandler ¶ added in v1.4.0
func (server *Server) SetAuthCommandHandler(handler AuthCommandHandler)
SetAuthCommandHandler sets a auth handler to handle auth commands.
func (*Server) SetCommandHandler ¶
func (server *Server) SetCommandHandler(handler UserCommandHandler)
SetCommandHandler sets a user handler to handle user commands.
type ServerConfig ¶ added in v1.4.0
type ServerConfig struct {
*Config
}
ServerConfig is a configuration for the Redis server.
func NewDefaultServerConfig ¶ added in v1.4.0
func NewDefaultServerConfig() *ServerConfig
NewDefaultServerConfig returns a default server configuration.
func (*ServerConfig) ConfigPort ¶ added in v1.4.0
func (cfg *ServerConfig) ConfigPort() int
ConfigPort returns a listen port number.
func (*ServerConfig) ConfigRequirePass ¶ added in v1.4.0
func (cfg *ServerConfig) ConfigRequirePass() (bool, string)
ConfigRequirePass returns a password.
func (*ServerConfig) RemoveRequirePass ¶ added in v1.4.0
func (cfg *ServerConfig) RemoveRequirePass()
RemoveRequirePass removes a password.
func (*ServerConfig) SetPort ¶ added in v1.4.0
func (cfg *ServerConfig) SetPort(port int)
SetPort sets a listen port number.
func (*ServerConfig) SetRequirePass ¶ added in v1.4.0
func (cfg *ServerConfig) SetRequirePass(password string)
SetRequirePass sets a password.
type ServerManagementCommandHandler ¶ added in v1.2.0
type ServerManagementCommandHandler interface { ConfigSet(conn *Conn, params map[string]string) (*Message, error) ConfigGet(conn *Conn, keys []string) (*Message, error) }
ServerManagementCommandHandler represents a hander interface for server management commands.
type SetCommandHandler ¶ added in v1.1.0
type SetCommandHandler interface { SAdd(conn *Conn, key string, members []string) (*Message, error) SMembers(conn *Conn, key string) (*Message, error) SRem(conn *Conn, key string, members []string) (*Message, error) }
SetCommandHandler represents a core command hander interface for set commands.
type StringCommandHandler ¶ added in v1.0.0
type StringCommandHandler interface { // Set represents a handler interface for SET, SETNX, SETEX, PSETEX, MSET and MSETNX commands. Set(conn *Conn, key string, val string, opt SetOption) (*Message, error) // Get represents a handler interface for GET and MGET commands. Get(conn *Conn, key string) (*Message, error) }
StringCommandHandler represents a core command hander interface for string commands. APPEND, DECR, DECRBY, GETRANGE, GETSET, INCR, INCRBY, MGET, MSET, MSETNX, SETRANGE, STRLEN commands are implemented by the StringCommandHandler.
type SystemCommandHandler ¶
type SystemCommandHandler interface { ConnectionManagementCommandHandler ServerManagementCommandHandler }
SystemCommandHandler represents a hander interface for system commands.
type UserCommandHandler ¶ added in v1.1.0
type UserCommandHandler interface { GenericCommandHandler StringCommandHandler HashCommandHandler ListCommandHandler SetCommandHandler ZSetCommandHandler }
UserCommandHandler represents a command hander interface for user commands.
type ZAddOption ¶ added in v1.1.0
type ZRangeOption ¶ added in v1.1.0
type ZSetCommandHandler ¶ added in v1.1.0
type ZSetCommandHandler interface { ZAdd(conn *Conn, key string, members []*ZSetMember, opt ZAddOption) (*Message, error) ZRange(conn *Conn, key string, start int, stop int, opt ZRangeOption) (*Message, error) ZRangeByScore(conn *Conn, key string, min float64, max float64, opt ZRangeOption) (*Message, error) ZRem(conn *Conn, key string, members []string) (*Message, error) ZScore(conn *Conn, key string, member string) (*Message, error) ZIncBy(conn *Conn, key string, inc float64, member string) (*Message, error) }
ZSetCommandHandler represents a core command hander interface for zset commands.
type ZSetMember ¶ added in v1.1.0
ZSetMember represents a parameter for ZSetCommandHandler.