-
Notifications
You must be signed in to change notification settings - Fork 556
/
consts.go
85 lines (61 loc) · 1.65 KB
/
consts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
}