forked from goinbox/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreply.go
90 lines (67 loc) · 1.58 KB
/
reply.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
86
87
88
89
90
package redis
import "github.com/garyburd/redigo/redis"
type Reply struct {
reply interface{}
Err error
}
func NewReply(reply interface{}, err error) *Reply {
return &Reply{
reply: reply,
Err: err,
}
}
func (r *Reply) SimpleReplyIsNil() bool {
if r.reply == nil {
return true
}
return false
}
func (r *Reply) ArrReplyIsNil() bool {
v, _ := redis.Values(r.reply, nil)
if len(v) == 0 {
return true
}
return false
}
func (r *Reply) Bool() (bool, error) {
return redis.Bool(r.reply, nil)
}
func (r *Reply) ByteSlices() ([][]byte, error) {
return redis.ByteSlices(r.reply, nil)
}
func (r *Reply) Bytes() ([]byte, error) {
return redis.Bytes(r.reply, nil)
}
func (r *Reply) Float64() (float64, error) {
return redis.Float64(r.reply, nil)
}
func (r *Reply) Int() (int, error) {
return redis.Int(r.reply, nil)
}
func (r *Reply) Int64() (int64, error) {
return redis.Int64(r.reply, nil)
}
func (r *Reply) Int64Map() (map[string]int64, error) {
return redis.Int64Map(r.reply, nil)
}
func (r *Reply) Ints() ([]int, error) {
return redis.Ints(r.reply, nil)
}
func (r *Reply) Int64s() ([]int64, error) {
return redis.Int64s(r.reply, nil)
}
func (r *Reply) Struct(s interface{}) error {
return redis.ScanStruct(r.reply.([]interface{}), s)
}
func (r *Reply) String() (string, error) {
return redis.String(r.reply, nil)
}
func (r *Reply) StringMap() (map[string]string, error) {
return redis.StringMap(r.reply, nil)
}
func (r *Reply) Strings() ([]string, error) {
return redis.Strings(r.reply, nil)
}
func (r *Reply) Uint64() (uint64, error) {
return redis.Uint64(r.reply, nil)
}