Documentation ¶
Index ¶
- Constants
- type Arguments
- type Config
- type Conn
- type ConnectionManagementCommandHandler
- type Executor
- type Executors
- type ExpireOption
- type GenericCommandHandler
- type HSetOption
- type HashCommandHandler
- type ListCommandHandler
- type MSetOption
- type Message
- func NewArrayMessage() *Message
- func NewArrayMessageWithArray(val *proto.Array) *Message
- func NewBulkMessage(msg string) *Message
- func NewErrorMessage(err error) *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 Server
- 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) SetAddress(addr string)
- func (server *Server) SetCommandHandler(handler UserCommandHandler)
- func (server *Server) SetPort(port int)
- func (server *Server) SetTracer(t tracer.Tracer)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- 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 OK = "OK" )
const (
ConfigSep = " "
)
const (
Version = "v1.3.2"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.
type Conn ¶ added in v1.3.0
type Conn struct { sync.Map tracer.SpanContext // contains filtered or unexported fields }
Conn represents a database connection.
func (*Conn) Database ¶ added in v1.3.0
Database returns the current selected database number in the connection.
func (*Conn) SetDatabase ¶ added in v1.3.0
SetDatabase sets th selected database number to 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 { // 1.0.0 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) }
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(conn *Conn, key string, fields []string) (*Message, error) HSet(conn *Conn, key string, field string, val string, opt HSetOption) (*Message, error) HGet(conn *Conn, key string, field string) (*Message, error) HGetAll(conn *Conn, key string) (*Message, error) HMSet(conn *Conn, key string, dict map[string]string) (*Message, error) HMGet(conn *Conn, key string, fields []string) (*Message, error) }
HashCommandHandler represents a core command hander interface for hash commands.
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 MSetOption ¶ added in v1.0.0
type MSetOption struct {
NX bool
}
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 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 Server ¶
type Server struct { Config tracer.Tracer Addr string Port int // 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) SetAddress ¶ added in v1.3.3
SetAddress sets a listen address.
func (*Server) SetCommandHandler ¶
func (server *Server) SetCommandHandler(handler UserCommandHandler)
SetCommandHandler sets a user handler to handle user commands.
type ServerManagementCommandHandler ¶ added in v1.2.0
type ServerManagementCommandHandler interface { // 2.0.0 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(conn *Conn, key string, val string, opt SetOption) (*Message, error) Get(conn *Conn, key string) (*Message, error) MSet(conn *Conn, dict map[string]string, opt MSetOption) (*Message, error) MGet(conn *Conn, keys []string) (*Message, error) }
StringHandler represents a core command hander interface for string commands.
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.