Documentation
¶
Index ¶
- Constants
- type Arguments
- type CommandHandler
- type DBContext
- type Executor
- type Executors
- type ExpireOption
- type GenericCommandHandler
- type HSetOption
- type HashCommandHandler
- type MSetOption
- type Message
- func NewArrayMessage() *Message
- func NewBulkMessage(msg string) *Message
- func NewErrorMessage(err error) *Message
- func NewIntegerMessage(val int) *Message
- func NewNilMessage() *Message
- func NewOKMessage() *Message
- func NewStringArrayMessage(strs []string) *Message
- func NewStringMessage(msg string) *Message
- type RenameOption
- type Server
- func (server *Server) Echo(ctx *DBContext, arg string) (*Message, error)
- func (server *Server) Ping(ctx *DBContext, arg string) (*Message, error)
- func (server *Server) Quit(ctx *DBContext) (*Message, error)
- func (server *Server) RegisterExexutor(cmd string, executor Executor)
- func (server *Server) Restart() error
- func (server *Server) Select(ctx *DBContext, index int) (*Message, error)
- func (server *Server) SetCommandHandler(handler CommandHandler)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- type SetOption
- type StringCommandHandler
- type SystemCommandHandler
Constants ¶
const ( LocalHost = "localhost" DefaultPort = 6379 OK = "OK" )
const (
Version = "v0.9.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandHandler ¶
type CommandHandler interface { GenericCommandHandler StringCommandHandler HashCommandHandler }
CommandHandler represents a command hander interface for user commands.
type DBContext ¶
type DBContext struct {
// contains filtered or unexported fields
}
DBContext represents a database connection context.
type ExpireOption ¶ added in v1.0.0
type GenericCommandHandler ¶ added in v1.0.0
type GenericCommandHandler interface { // 1.0.0 Del(ctx *DBContext, keys []string) (*Message, error) Exists(ctx *DBContext, keys []string) (*Message, error) Expire(ctx *DBContext, key string, opt ExpireOption) (*Message, error) Keys(ctx *DBContext, pattern string) (*Message, error) Rename(ctx *DBContext, key string, newkey string, opt RenameOption) (*Message, error) Type(ctx *DBContext, key string) (*Message, error) TTL(ctx *DBContext, 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(ctx *DBContext, key string, fields []string) (*Message, error) HSet(ctx *DBContext, key string, field string, val string, opt HSetOption) (*Message, error) HGet(ctx *DBContext, key string, field string) (*Message, error) HGetAll(ctx *DBContext, key string) (*Message, error) HMSet(ctx *DBContext, key string, dict map[string]string) (*Message, error) HMGet(ctx *DBContext, key string, fields []string) (*Message, error) }
HashCommandHandler represents a core command hander interface for hash 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 NewBulkMessage ¶
NewBulkMessage creates a bulk string message.
func NewErrorMessage ¶
NewErrorMessage creates an error 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 RenameOption ¶ added in v1.0.0
type RenameOption struct {
NX bool
}
type Server ¶
Server is an instance for Redis protocols.
func (*Server) RegisterExexutor ¶ added in v1.0.0
RegisterExexutor sets a command executor.
func (*Server) SetCommandHandler ¶
func (server *Server) SetCommandHandler(handler CommandHandler)
SetCommandHandler sets a user handler to handle user commands.
type StringCommandHandler ¶ added in v1.0.0
type StringCommandHandler interface { Set(ctx *DBContext, key string, val string, opt SetOption) (*Message, error) Get(ctx *DBContext, key string) (*Message, error) MSet(ctx *DBContext, dict map[string]string, opt MSetOption) (*Message, error) MGet(ctx *DBContext, keys []string) (*Message, error) }
StringHandler represents a core command hander interface for string commands.
type SystemCommandHandler ¶
type SystemCommandHandler interface { Ping(ctx *DBContext, arg string) (*Message, error) Echo(ctx *DBContext, arg string) (*Message, error) Select(ctx *DBContext, index int) (*Message, error) Quit(ctx *DBContext) (*Message, error) }
SystemCommandHandler represents a hander interface for system commands.