mirror of
https://github.com/HDT3213/godis.git
synced 2025-11-03 11:02:17 +08:00
rename godis/redis/reply to godis/redis/protocol
This commit is contained in:
85
redis/protocol/consts.go
Normal file
85
redis/protocol/consts.go
Normal file
@@ -0,0 +1,85 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user