-
Notifications
You must be signed in to change notification settings - Fork 0
/
zset.go
67 lines (51 loc) · 2.46 KB
/
zset.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
// Package redis
// Date: 2023/12/4 14:01
// Author: Amu
// Description:
package redis
import "github.com/go-redis/redis/v8"
// ======================== zset 指令 ======================== //
func (rc *Client) ZAdd(key string, member interface{}, score float64) (int64, error) {
return rc.UniversalClient.ZAdd(ctx, key, &redis.Z{Score: score, Member: member}).Result()
}
// ZIncrBy 增加 member 的分值,返回更新后的分值
func (rc *Client) ZIncrBy(key string, member string, score float64) (float64, error) {
return rc.UniversalClient.ZIncrBy(ctx, key, score, member).Result()
}
// ZRange 获取根据 score 排序后的 [start, end] 元素
func (rc *Client) ZRange(key string, start int64, end int64) ([]string, error) {
return rc.UniversalClient.ZRange(ctx, key, start, end).Result()
}
func (rc *Client) ZRevRange(key string, start int64, end int64) ([]string, error) {
return rc.UniversalClient.ZRange(ctx, key, start, end).Result()
}
func (rc *Client) ZRangeByScore(key string, minScore string, maxScore string) ([]string, error) {
return rc.UniversalClient.ZRangeByScore(ctx, key, &redis.ZRangeBy{Min: minScore, Max: maxScore}).Result()
}
func (rc *Client) ZRevRangeByScore(key string, minScore string, maxScore string) ([]string, error) {
return rc.UniversalClient.ZRangeByScore(ctx, key, &redis.ZRangeBy{Min: minScore, Max: maxScore}).Result()
}
func (rc *Client) ZCard(key string) (int64, error) {
return rc.UniversalClient.ZCard(ctx, key).Result()
}
func (rc *Client) ZCount(key string, minScore, maxScore string) (int64, error) {
return rc.UniversalClient.ZCount(ctx, key, minScore, maxScore).Result()
}
func (rc *Client) ZScore(key string, score string) (float64, error) {
return rc.UniversalClient.ZScore(ctx, key, score).Result()
}
func (rc *Client) ZRank(key string, value string) (int64, error) {
return rc.UniversalClient.ZRank(ctx, key, value).Result()
}
func (rc *Client) ZRevRank(key string, value string) (int64, error) {
return rc.UniversalClient.ZRank(ctx, key, value).Result()
}
func (rc *Client) ZRem(key string, value string) (int64, error) {
return rc.UniversalClient.ZRem(ctx, key, value).Result()
}
func (rc *Client) ZRemRangeByRank(key string, startIndex, endIndex int64) (int64, error) {
return rc.UniversalClient.ZRemRangeByRank(ctx, key, startIndex, endIndex).Result()
}
func (rc *Client) ZRemRangeByScore(key string, minScore, maxScore string) (int64, error) {
return rc.UniversalClient.ZRemRangeByScore(ctx, key, minScore, maxScore).Result()
}