mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 08:46:56 +08:00
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package reply
|
|
|
|
// PongReply is +PONG
|
|
type PongReply struct{}
|
|
|
|
var pongBytes = []byte("+PONG\r\n")
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *PongReply) ToBytes() []byte {
|
|
return pongBytes
|
|
}
|
|
|
|
// OkReply is +OK
|
|
type OkReply struct{}
|
|
|
|
var okBytes = []byte("+OK\r\n")
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *OkReply) ToBytes() []byte {
|
|
return okBytes
|
|
}
|
|
|
|
var nullBulkBytes = []byte("$-1\r\n")
|
|
|
|
// NullBulkReply is empty string
|
|
type NullBulkReply struct{}
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *NullBulkReply) ToBytes() []byte {
|
|
return nullBulkBytes
|
|
}
|
|
|
|
// MakeNullBulkReply creates a new NullBulkReply
|
|
func MakeNullBulkReply() *NullBulkReply {
|
|
return &NullBulkReply{}
|
|
}
|
|
|
|
var emptyMultiBulkBytes = []byte("*0\r\n")
|
|
|
|
// EmptyMultiBulkReply is a empty list
|
|
type EmptyMultiBulkReply struct{}
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *EmptyMultiBulkReply) ToBytes() []byte {
|
|
return emptyMultiBulkBytes
|
|
}
|
|
|
|
// MakeEmptyMultiBulkReply creates EmptyMultiBulkReply
|
|
func MakeEmptyMultiBulkReply() *EmptyMultiBulkReply {
|
|
return &EmptyMultiBulkReply{}
|
|
}
|
|
|
|
// NoReply respond nothing, for commands like subscribe
|
|
type NoReply struct{}
|
|
|
|
var noBytes = []byte("")
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *NoReply) ToBytes() []byte {
|
|
return noBytes
|
|
}
|