Documentation
¶
Index ¶
- Constants
- type Arguments
- type DBContext
- 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) 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 UserCommandHandler)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- type SetCommandHandler
- type SetOption
- type StringCommandHandler
- type SystemCommandHandler
- type UserCommandHandler
- type ZAddOption
- type ZRangeOption
- type ZSetCommandHandler
- type ZSetMember
Constants ¶
const ( LocalHost = "localhost" DefaultPort = 6379 OK = "OK" )
const (
Version = "v1.1.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ListCommandHandler ¶ added in v1.1.0
type ListCommandHandler interface { LPush(ctx *DBContext, key string, elements []string, opt PushOption) (*Message, error) RPush(ctx *DBContext, key string, elements []string, opt PushOption) (*Message, error) LPop(ctx *DBContext, key string, count int) (*Message, error) RPop(ctx *DBContext, key string, count int) (*Message, error) LRange(ctx *DBContext, key string, start int, stop int) (*Message, error) LIndex(ctx *DBContext, key string, index int) (*Message, error) LLen(ctx *DBContext, 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 ¶
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 UserCommandHandler)
SetCommandHandler sets a user handler to handle user commands.
type SetCommandHandler ¶ added in v1.1.0
type SetCommandHandler interface { SAdd(ctx *DBContext, key string, members []string) (*Message, error) SMembers(ctx *DBContext, key string) (*Message, error) SRem(ctx *DBContext, 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(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.
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(ctx *DBContext, key string, members []*ZSetMember, opt ZAddOption) (*Message, error) ZRange(ctx *DBContext, key string, start int, stop int, opt ZRangeOption) (*Message, error) ZRangeByScore(ctx *DBContext, key string, min float64, max float64, opt ZRangeOption) (*Message, error) ZRem(ctx *DBContext, key string, members []string) (*Message, error) ZScore(ctx *DBContext, key string, member string) (*Message, error) ZIncBy(ctx *DBContext, 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.