feat(redis): add ZaddFloat & ZaddFloatCtx (#2291)

This commit is contained in:
chen quan
2022-08-24 21:02:16 +08:00
committed by GitHub
parent 4cb68a034a
commit 0316b6e10e
4 changed files with 55 additions and 34 deletions

View File

@@ -1836,8 +1836,19 @@ func (s *Redis) Zadd(key string, score int64, value string) (bool, error) {
return s.ZaddCtx(context.Background(), key, score, value)
}
// ZaddFloat is the implementation of redis zadd command.
func (s *Redis) ZaddFloat(key string, score float64, value string) (bool, error) {
return s.ZaddFloatCtx(context.Background(), key, score, value)
}
// ZaddCtx is the implementation of redis zadd command.
func (s *Redis) ZaddCtx(ctx context.Context, key string, score int64, value string) (
val bool, err error) {
return s.ZaddFloatCtx(ctx, key, float64(score), value)
}
// ZaddFloatCtx is the implementation of redis zadd command.
func (s *Redis) ZaddFloatCtx(ctx context.Context, key string, score float64, value string) (
val bool, err error) {
err = s.brk.DoWithAcceptable(func() error {
conn, err := getRedis(s)
@@ -1846,7 +1857,7 @@ func (s *Redis) ZaddCtx(ctx context.Context, key string, score int64, value stri
}
v, err := conn.ZAdd(ctx, key, &red.Z{
Score: float64(score),
Score: score,
Member: value,
}).Result()
if err != nil {