-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreply.go
111 lines (86 loc) · 2.19 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package redis_pack
import (
"github.com/gomodule/redigo/redis"
)
type Reply struct {
reply interface{}
error error
}
func getReply(rp interface{}, err error) *Reply {
return &Reply{reply: rp, error: err}
}
func (r *Reply) Result() (interface{}, error) {
return r.reply, r.error
}
func (r *Reply) Error() error {
return r.error
}
func (r *Reply) Int64() (int64, error) {
return redis.Int64(r.reply, r.error)
}
func (r *Reply) Int() (int, error) {
return redis.Int(r.reply, r.error)
}
func (r *Reply) Uint64() (uint64, error) {
return redis.Uint64(r.reply, r.error)
}
func (r *Reply) float64() (float64, error) {
return redis.Float64(r.reply, r.error)
}
func (r *Reply) Float64() (float64, error) {
return redis.Float64(r.reply, r.error)
}
func (r *Reply) String() (string, error) {
return redis.String(r.reply, r.error)
}
func (r *Reply) Bytes() ([]byte, error) {
return redis.Bytes(r.reply, r.error)
}
func (r *Reply) Bool() (bool, error) {
return redis.Bool(r.reply, r.error)
}
func (r *Reply) Float64s() ([]float64, error) {
return redis.Float64s(r.reply, r.error)
}
func (r *Reply) Strings() ([]string, error) {
return redis.Strings(r.reply, r.error)
}
func (r *Reply) ByteSlices() ([][]byte, error) {
return redis.ByteSlices(r.reply, r.error)
}
func (r *Reply) Int64s() ([]int64, error) {
return redis.Int64s(r.reply, r.error)
}
func (r *Reply) Ints() ([]int, error) {
return redis.Ints(r.reply, r.error)
}
func (r *Reply) StringMap() (map[string]string, error) {
return redis.StringMap(r.reply, r.error)
}
func (r *Reply) IntMap() (map[string]int, error) {
return redis.IntMap(r.reply, r.error)
}
func (r *Reply) Int64Map() (map[string]int64, error) {
return redis.Int64Map(r.reply, r.error)
}
func (r *Reply) Positions() ([]*[2]float64, error) {
return redis.Positions(r.reply, r.error)
}
func (r *Reply) Values() ([]interface{}, error) {
return redis.Values(r.reply, r.error)
}
// obj为一个指针对象
func (r *Reply) ScanStruct(obj interface{}) error {
v, err := r.Values()
if err != nil {
return err
}
return redis.ScanStruct(v, obj)
}
func (r *Reply) ScanSlice(obj interface{}) error {
v, err := r.Values()
if err != nil {
return err
}
return redis.ScanSlice(v, obj)
}