Skip to content

Commit

Permalink
Merge pull request #98 from pinguo-yangbing/master
Browse files Browse the repository at this point in the history
redis
  • Loading branch information
pinguo-yangbing authored Jan 7, 2021
2 parents 724f1d9 + d5512c0 commit 802a5f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion adapter/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type IRedis interface {
MDel(keys []string) bool
Exists(key string) bool
Incr(key string, delta int) int
IncrBy(key string, delta int) (int, error)
Do(cmd string, args ...interface{}) interface{}
ExpireAt(key string, timestamp int64) bool
Expire(key string, expire time.Duration) bool
Expand All @@ -113,7 +114,7 @@ type IRedis interface {
HGetAll(key string) map[string]*value.Value
HMSet(key string, fv ...interface{}) bool
HMGet(key string, fields ...interface{}) map[string]*value.Value
HIncrBy(key, field string, delta int) int
HIncrBy(key, field string, delta int) (int,error)
ZRange(key string, start, end int) []*value.Value
ZRevRange(key string, start, end int) []*value.Value
ZRangeWithScores(key string, start, end int) []*redis.ZV
Expand Down
16 changes: 14 additions & 2 deletions adapter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ func (r *Redis) Incr(key string, delta int) int {
return res
}

func (r *Redis) IncrBy(key string, delta int) (int, error) {
profile := "Redis.IncrBy"
r.Context().ProfileStart(profile)
defer r.Context().ProfileStop(profile)
defer r.handlePanic()

res, err := r.client.Incr(key, delta)
r.parseErr(err)

return res,err
}

// 支持的命令请查阅:Redis.allRedisCmd
// args = [0:"key"]
// Example:
Expand Down Expand Up @@ -424,7 +436,7 @@ func (r *Redis) HMGet(key string,fields ...interface{}) map[string]*value.Value
return res
}

func (r *Redis) HIncrBy(key, field string, delta int) int {
func (r *Redis) HIncrBy(key, field string, delta int) (int,error) {
profile := "Redis.HIncrBy"
r.Context().ProfileStart(profile)
defer r.Context().ProfileStop(profile)
Expand All @@ -433,7 +445,7 @@ func (r *Redis) HIncrBy(key, field string, delta int) int {
res, err := r.client.HIncrBy(key,field, delta)
r.parseErr(err)

return res
return res,err
}

func (r *Redis) ZRange(key string, start, end int) []*value.Value {
Expand Down
20 changes: 18 additions & 2 deletions test/mock/adapter/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 802a5f9

Please sign in to comment.