mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 00:42:43 +08:00
86 lines
1.7 KiB
Go
86 lines
1.7 KiB
Go
package protocol
|
|
|
|
// 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 theOkReply = new(OkReply)
|
|
|
|
// MakeOkReply returns a ok protocol
|
|
func MakeOkReply() *OkReply {
|
|
return theOkReply
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
// QueuedReply is +QUEUED
|
|
type QueuedReply struct{}
|
|
|
|
var queuedBytes = []byte("+QUEUED\r\n")
|
|
|
|
// ToBytes marshal redis.Reply
|
|
func (r *QueuedReply) ToBytes() []byte {
|
|
return queuedBytes
|
|
}
|
|
|
|
var theQueuedReply = new(QueuedReply)
|
|
|
|
// MakeQueuedReply returns a QUEUED protocol
|
|
func MakeQueuedReply() *QueuedReply {
|
|
return theQueuedReply
|
|
}
|