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

@@ -110,7 +110,9 @@ type (
Ttl(key string) (int, error)
TtlCtx(ctx context.Context, key string) (int, error)
Zadd(key string, score int64, value string) (bool, error)
ZaddFloat(key string, score float64, value string) (bool, error)
ZaddCtx(ctx context.Context, key string, score int64, value string) (bool, error)
ZaddFloatCtx(ctx context.Context, key string, score float64, value string) (bool, error)
Zadds(key string, ps ...redis.Pair) (int64, error)
ZaddsCtx(ctx context.Context, key string, ps ...redis.Pair) (int64, error)
Zcard(key string) (int, error)
@@ -787,13 +789,21 @@ func (cs clusterStore) Zadd(key string, score int64, value string) (bool, error)
return cs.ZaddCtx(context.Background(), key, score, value)
}
func (cs clusterStore) ZaddFloat(key string, score float64, value string) (bool, error) {
return cs.ZaddFloatCtx(context.Background(), key, score, value)
}
func (cs clusterStore) ZaddCtx(ctx context.Context, key string, score int64, value string) (bool, error) {
return cs.ZaddFloatCtx(ctx, key, float64(score), value)
}
func (cs clusterStore) ZaddFloatCtx(ctx context.Context, key string, score float64, value string) (bool, error) {
node, err := cs.getRedis(key)
if err != nil {
return false, err
}
return node.ZaddCtx(ctx, key, score, value)
return node.ZaddFloatCtx(ctx, key, score, value)
}
func (cs clusterStore) Zadds(key string, ps ...redis.Pair) (int64, error) {