-
Notifications
You must be signed in to change notification settings - Fork 8
/
redis_client_proxy.go
122 lines (119 loc) · 4.17 KB
/
redis_client_proxy.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
112
113
114
115
116
117
118
119
120
121
122
package redis_orm
import (
"github.com/go-redis/redis"
)
type RedisClientProxy struct {
engine *Engine
redisClient redis.Cmdable
}
func NewRedisCliProxy(redisCli redis.Cmdable) *RedisClientProxy {
return &RedisClientProxy{
redisClient: redisCli,
}
}
func (c *RedisClientProxy) HMSet(key string, fields map[string]interface{}) *redis.StatusCmd {
if len(fields) == 0 {
return &redis.StatusCmd{}
}
val := c.redisClient.HMSet(key, fields)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HIncrby(key string, field string, intVal int64) *redis.IntCmd {
val := c.redisClient.HIncrBy(key, field, intVal)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HIncrbyFloat(key string, field string, intVal float64) *redis.FloatCmd {
val := c.redisClient.HIncrByFloat(key, field, intVal)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HGet(key string, field string) *redis.StringCmd {
val := c.redisClient.HGet(key, field)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HMGet(key string, fields ...string) *redis.SliceCmd {
if len(fields) == 0 {
return &redis.SliceCmd{}
}
val := c.redisClient.HMGet(key, fields...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HIncrBy(key, field string, incr int64) *redis.IntCmd {
val := c.redisClient.HIncrBy(key, field, incr)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HIncrByFloat(key, field string, incr float64) *redis.FloatCmd {
val := c.redisClient.HIncrByFloat(key, field, incr)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) HDel(key string, fields ...string) *redis.IntCmd {
if len(fields) == 0 {
return &redis.IntCmd{}
}
val := c.redisClient.HDel(key, fields...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) Del(keys ...string) *redis.IntCmd {
if len(keys) == 0 {
return &redis.IntCmd{}
}
val := c.redisClient.Del(keys...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZCount(key, min, max string) *redis.IntCmd {
val := c.redisClient.ZCount(key, min, max)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZScore(key, member string) *redis.FloatCmd {
val := c.redisClient.ZScore(key, member)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZRangeByScore(key string, opt redis.ZRangeBy) *redis.StringSliceCmd {
val := c.redisClient.ZRangeByScore(key, opt)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZRevRangeByScore(key string, opt redis.ZRangeBy) *redis.StringSliceCmd {
val := c.redisClient.ZRevRangeByScore(key, opt)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZRem(key string, members ...interface{}) *redis.IntCmd {
if len(members) == 0 {
return &redis.IntCmd{}
}
val := c.redisClient.ZRem(key, members...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZRemRangeByScores(key string, min, max string) *redis.IntCmd {
val := c.redisClient.ZRemRangeByScore(key, min, max)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZAdd(key string, members ...redis.Z) *redis.IntCmd {
if len(members) == 0 {
return &redis.IntCmd{}
}
val := c.redisClient.ZAdd(key, members...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}
func (c *RedisClientProxy) ZAddNX(key string, members ...redis.Z) *redis.IntCmd {
if len(members) == 0 {
return &redis.IntCmd{}
}
val := c.redisClient.ZAddNX(key, members...)
c.engine.Printfln("========redis command========\n%v", val.String())
return val
}