|
|
@ -483,13 +483,8 @@ func (s *Redis) ExistsManyCtx(ctx context.Context, keys ...string) (val int64, e
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.Exists(ctx, keys...).Result()
|
|
|
|
val, err = conn.Exists(ctx, keys...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -543,13 +538,8 @@ func (s *Redis) GeoAddCtx(ctx context.Context, key string, geoLocation ...*GeoLo
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoAdd(ctx, key, geoLocation...).Result()
|
|
|
|
val, err = conn.GeoAdd(ctx, key, geoLocation...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -569,13 +559,8 @@ func (s *Redis) GeoDistCtx(ctx context.Context, key, member1, member2, unit stri
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoDist(ctx, key, member1, member2, unit).Result()
|
|
|
|
val, err = conn.GeoDist(ctx, key, member1, member2, unit).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -595,13 +580,8 @@ func (s *Redis) GeoHashCtx(ctx context.Context, key string, members ...string) (
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoHash(ctx, key, members...).Result()
|
|
|
|
val, err = conn.GeoHash(ctx, key, members...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -622,13 +602,8 @@ func (s *Redis) GeoRadiusCtx(ctx context.Context, key string, longitude, latitud
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoRadius(ctx, key, longitude, latitude, query).Result()
|
|
|
|
val, err = conn.GeoRadius(ctx, key, longitude, latitude, query).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -648,13 +623,8 @@ func (s *Redis) GeoRadiusByMemberCtx(ctx context.Context, key, member string,
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoRadiusByMember(ctx, key, member, query).Result()
|
|
|
|
val, err = conn.GeoRadiusByMember(ctx, key, member, query).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -674,13 +644,8 @@ func (s *Redis) GeoPosCtx(ctx context.Context, key string, members ...string) (
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.GeoPos(ctx, key, members...).Result()
|
|
|
|
val, err = conn.GeoPos(ctx, key, members...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -699,7 +664,7 @@ func (s *Redis) GetCtx(ctx context.Context, key string) (val string, err error)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if val, err = conn.Get(ctx, key).Result(); err == red.Nil {
|
|
|
|
if val, err = conn.Get(ctx, key).Result(); errors.Is(err, red.Nil) {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
} else if err != nil {
|
|
|
|
} else if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -749,7 +714,7 @@ func (s *Redis) GetSetCtx(ctx context.Context, key, value string) (val string, e
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if val, err = conn.GetSet(ctx, key, value).Result(); err == red.Nil {
|
|
|
|
if val, err = conn.GetSet(ctx, key, value).Result(); errors.Is(err, red.Nil) {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -875,17 +840,16 @@ func (s *Redis) HincrbyFloat(key, field string, increment float64) (float64, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// HincrbyFloatCtx is the implementation of redis hincrbyfloat command.
|
|
|
|
// HincrbyFloatCtx is the implementation of redis hincrbyfloat command.
|
|
|
|
func (s *Redis) HincrbyFloatCtx(ctx context.Context, key, field string, increment float64) (val float64, err error) {
|
|
|
|
func (s *Redis) HincrbyFloatCtx(ctx context.Context, key, field string, increment float64) (
|
|
|
|
|
|
|
|
val float64, err error) {
|
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
|
err = s.brk.DoWithAcceptable(func() error {
|
|
|
|
conn, err := getRedis(s)
|
|
|
|
conn, err := getRedis(s)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val, err = conn.HIncrByFloat(ctx, key, field, increment).Result()
|
|
|
|
val, err = conn.HIncrByFloat(ctx, key, field, increment).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -1353,11 +1317,7 @@ func (s *Redis) MsetCtx(ctx context.Context, fieldsAndValues ...any) (val string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val, err = conn.MSet(ctx, fieldsAndValues...).Result()
|
|
|
|
val, err = conn.MSet(ctx, fieldsAndValues...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -2052,6 +2012,7 @@ func (s *Redis) TtlCtx(ctx context.Context, key string) (val int, err error) {
|
|
|
|
// -1 means key exists but has no expire
|
|
|
|
// -1 means key exists but has no expire
|
|
|
|
val = int(duration)
|
|
|
|
val = int(duration)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
@ -2157,13 +2118,8 @@ func (s *Redis) ZaddsCtx(ctx context.Context, key string, ps ...Pair) (val int64
|
|
|
|
zs = append(zs, z)
|
|
|
|
zs = append(zs, z)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v, err := conn.ZAdd(ctx, key, zs...).Result()
|
|
|
|
val, err = conn.ZAdd(ctx, key, zs...).Result()
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = v
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -2283,6 +2239,7 @@ func (s *Redis) ZscoreByFloatCtx(ctx context.Context, key, value string) (val fl
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val, err = conn.ZScore(ctx, key, value).Result()
|
|
|
|
val, err = conn.ZScore(ctx, key, value).Result()
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}, acceptable)
|
|
|
|
}, acceptable)
|
|
|
@ -2947,7 +2904,7 @@ func withHook(hook red.Hook) Option {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func acceptable(err error) bool {
|
|
|
|
func acceptable(err error) bool {
|
|
|
|
return err == nil || err == red.Nil || errors.Is(err, context.Canceled)
|
|
|
|
return err == nil || errors.Is(err, red.Nil) || errors.Is(err, context.Canceled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func getRedis(r *Redis) (RedisNode, error) {
|
|
|
|
func getRedis(r *Redis) (RedisNode, error) {
|
|
|
|