Documentation ¶
Index ¶
- Variables
- func DumpProtos() (s string)
- func RegisterProto(name string, f func() Proto) interface{}
- type Proto
- type RedisProto
- func (this *RedisProto) MarshalError(e error) []byte
- func (this *RedisProto) MarshalRequest(command string, args ...interface{}) ([]byte, error)
- func (this *RedisProto) MarshalResponse(c *C.Command) []byte
- func (this *RedisProto) UnmarshalRequest(buf []byte) (*C.Command, int, error)
- func (this *RedisProto) UnmarshalResponse(buf []byte) (*Reply, int, error)
- type Reply
- type SimpleProto
- func (this *SimpleProto) MarshalError(e error) []byte
- func (this *SimpleProto) MarshalRequest(command string, args ...interface{}) ([]byte, error)
- func (this *SimpleProto) MarshalResponse(c *C.Command) []byte
- func (this *SimpleProto) UnmarshalRequest(buf []byte) (*C.Command, int, error)
- func (this *SimpleProto) UnmarshalResponse(buf []byte) (*Reply, int, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultProto = "redis"
Functions ¶
Types ¶
type Proto ¶
type Proto interface { MarshalRequest(command string, args ...interface{}) ([]byte, error) UnmarshalRequest([]byte) (*C.Command, int, error) MarshalResponse(*C.Command) []byte UnmarshalResponse(buf []byte) (*Reply, int, error) MarshalError(error) []byte }
var GProto Proto
type RedisProto ¶
type RedisProto struct { }
func (*RedisProto) MarshalError ¶
func (this *RedisProto) MarshalError(e error) []byte
func (*RedisProto) MarshalRequest ¶
func (this *RedisProto) MarshalRequest(command string, args ...interface{}) ([]byte, error)
func (*RedisProto) MarshalResponse ¶
func (this *RedisProto) MarshalResponse(c *C.Command) []byte
func (*RedisProto) UnmarshalRequest ¶
type SimpleProto ¶
type SimpleProto struct { }
一个不能包含空格、换行符,每行一条命令的简单字符协议, 可以用telnet交互
Request:
set a 1\n get a\n
Response: (+表示请求成功, -表示有error)
+OK\n +1\n -Key not exists\n
func (*SimpleProto) MarshalError ¶
func (this *SimpleProto) MarshalError(e error) []byte
func (*SimpleProto) MarshalRequest ¶
func (this *SimpleProto) MarshalRequest(command string, args ...interface{}) ([]byte, error)
func (*SimpleProto) MarshalResponse ¶
func (this *SimpleProto) MarshalResponse(c *C.Command) []byte
func (*SimpleProto) UnmarshalRequest ¶
Click to show internal directories.
Click to hide internal directories.