protocol-redis 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -2
- data/context/getting-started.md +55 -0
- data/context/index.yaml +13 -0
- data/lib/protocol/redis/cluster/methods/generic.rb +94 -0
- data/lib/protocol/redis/cluster/methods/pubsub.rb +27 -0
- data/lib/protocol/redis/cluster/methods/scripting.rb +93 -0
- data/lib/protocol/redis/cluster/methods/streams.rb +204 -0
- data/lib/protocol/redis/cluster/methods/strings.rb +304 -0
- data/lib/protocol/redis/cluster/methods.rb +27 -0
- data/lib/protocol/redis/connection.rb +41 -12
- data/lib/protocol/redis/error.rb +6 -0
- data/lib/protocol/redis/methods/cluster.rb +9 -7
- data/lib/protocol/redis/methods/connection.rb +9 -8
- data/lib/protocol/redis/methods/counting.rb +9 -8
- data/lib/protocol/redis/methods/generic.rb +100 -99
- data/lib/protocol/redis/methods/geospatial.rb +42 -49
- data/lib/protocol/redis/methods/hashes.rb +84 -83
- data/lib/protocol/redis/methods/lists.rb +75 -74
- data/lib/protocol/redis/methods/pubsub.rb +5 -4
- data/lib/protocol/redis/methods/scripting.rb +19 -20
- data/lib/protocol/redis/methods/server.rb +13 -9
- data/lib/protocol/redis/methods/sets.rb +42 -41
- data/lib/protocol/redis/methods/sorted_sets.rb +110 -109
- data/lib/protocol/redis/methods/streams.rb +48 -47
- data/lib/protocol/redis/methods/strings.rb +112 -109
- data/lib/protocol/redis/methods.rb +16 -14
- data/lib/protocol/redis/version.rb +1 -1
- data/lib/protocol/redis.rb +9 -2
- data/readme.md +49 -21
- data/releases.md +98 -0
- data.tar.gz.sig +0 -0
- metadata +13 -9
- metadata.gz.sig +0 -0
@@ -6,119 +6,120 @@
|
|
6
6
|
module Protocol
|
7
7
|
module Redis
|
8
8
|
module Methods
|
9
|
+
# Methods for managing Redis sets.
|
9
10
|
module Sets
|
10
11
|
# Add one or more members to a set. O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.
|
11
|
-
#
|
12
|
-
# @
|
13
|
-
# @
|
12
|
+
# See <https://redis.io/commands/sadd> for more details.
|
13
|
+
# @parameter key [Key]
|
14
|
+
# @parameter member [String]
|
14
15
|
def sadd(*arguments)
|
15
16
|
call("SADD", *arguments)
|
16
17
|
end
|
17
18
|
|
18
19
|
# Get the number of members in a set. O(1).
|
19
|
-
#
|
20
|
-
# @
|
20
|
+
# See <https://redis.io/commands/scard> for more details.
|
21
|
+
# @parameter key [Key]
|
21
22
|
def scard(*arguments)
|
22
23
|
call("SCARD", *arguments)
|
23
24
|
end
|
24
25
|
|
25
26
|
# Subtract multiple sets. O(N) where N is the total number of elements in all given sets.
|
26
|
-
#
|
27
|
-
# @
|
27
|
+
# See <https://redis.io/commands/sdiff> for more details.
|
28
|
+
# @parameter key [Key]
|
28
29
|
def sdiff(*arguments)
|
29
30
|
call("SDIFF", *arguments)
|
30
31
|
end
|
31
32
|
|
32
33
|
# Subtract multiple sets and store the resulting set in a key. O(N) where N is the total number of elements in all given sets.
|
33
|
-
#
|
34
|
-
# @
|
35
|
-
# @
|
34
|
+
# See <https://redis.io/commands/sdiffstore> for more details.
|
35
|
+
# @parameter destination [Key]
|
36
|
+
# @parameter key [Key]
|
36
37
|
def sdiffstore(*arguments)
|
37
38
|
call("SDIFFSTORE", *arguments)
|
38
39
|
end
|
39
40
|
|
40
41
|
# Intersect multiple sets. O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.
|
41
|
-
#
|
42
|
-
# @
|
42
|
+
# See <https://redis.io/commands/sinter> for more details.
|
43
|
+
# @parameter key [Key]
|
43
44
|
def sinter(*arguments)
|
44
45
|
call("SINTER", *arguments)
|
45
46
|
end
|
46
47
|
|
47
48
|
# Intersect multiple sets and store the resulting set in a key. O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.
|
48
|
-
#
|
49
|
-
# @
|
50
|
-
# @
|
49
|
+
# See <https://redis.io/commands/sinterstore> for more details.
|
50
|
+
# @parameter destination [Key]
|
51
|
+
# @parameter key [Key]
|
51
52
|
def sinterstore(*arguments)
|
52
53
|
call("SINTERSTORE", *arguments)
|
53
54
|
end
|
54
55
|
|
55
56
|
# Determine if a given value is a member of a set. O(1).
|
56
|
-
#
|
57
|
-
# @
|
58
|
-
# @
|
57
|
+
# See <https://redis.io/commands/sismember> for more details.
|
58
|
+
# @parameter key [Key]
|
59
|
+
# @parameter member [String]
|
59
60
|
def sismember(*arguments)
|
60
61
|
call("SISMEMBER", *arguments)
|
61
62
|
end
|
62
63
|
|
63
64
|
# Get all the members in a set. O(N) where N is the set cardinality.
|
64
|
-
#
|
65
|
-
# @
|
65
|
+
# See <https://redis.io/commands/smembers> for more details.
|
66
|
+
# @parameter key [Key]
|
66
67
|
def smembers(*arguments)
|
67
68
|
call("SMEMBERS", *arguments)
|
68
69
|
end
|
69
70
|
|
70
71
|
# Move a member from one set to another. O(1).
|
71
|
-
#
|
72
|
-
# @
|
73
|
-
# @
|
74
|
-
# @
|
72
|
+
# See <https://redis.io/commands/smove> for more details.
|
73
|
+
# @parameter source [Key]
|
74
|
+
# @parameter destination [Key]
|
75
|
+
# @parameter member [String]
|
75
76
|
def smove(*arguments)
|
76
77
|
call("SMOVE", *arguments)
|
77
78
|
end
|
78
79
|
|
79
80
|
# Remove and return one or multiple random members from a set. O(1).
|
80
|
-
#
|
81
|
-
# @
|
82
|
-
# @
|
81
|
+
# See <https://redis.io/commands/spop> for more details.
|
82
|
+
# @parameter key [Key]
|
83
|
+
# @parameter count [Integer]
|
83
84
|
def spop(*arguments)
|
84
85
|
call("SPOP", *arguments)
|
85
86
|
end
|
86
87
|
|
87
88
|
# Get one or multiple random members from a set. Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.
|
88
|
-
#
|
89
|
-
# @
|
90
|
-
# @
|
89
|
+
# See <https://redis.io/commands/srandmember> for more details.
|
90
|
+
# @parameter key [Key]
|
91
|
+
# @parameter count [Integer]
|
91
92
|
def srandmember(*arguments)
|
92
93
|
call("SRANDMEMBER", *arguments)
|
93
94
|
end
|
94
95
|
|
95
96
|
# Remove one or more members from a set. O(N) where N is the number of members to be removed.
|
96
|
-
#
|
97
|
-
# @
|
98
|
-
# @
|
97
|
+
# See <https://redis.io/commands/srem> for more details.
|
98
|
+
# @parameter key [Key]
|
99
|
+
# @parameter member [String]
|
99
100
|
def srem(*arguments)
|
100
101
|
call("SREM", *arguments)
|
101
102
|
end
|
102
103
|
|
103
104
|
# Add multiple sets. O(N) where N is the total number of elements in all given sets.
|
104
|
-
#
|
105
|
-
# @
|
105
|
+
# See <https://redis.io/commands/sunion> for more details.
|
106
|
+
# @parameter key [Key]
|
106
107
|
def sunion(*arguments)
|
107
108
|
call("SUNION", *arguments)
|
108
109
|
end
|
109
110
|
|
110
111
|
# Add multiple sets and store the resulting set in a key. O(N) where N is the total number of elements in all given sets.
|
111
|
-
#
|
112
|
-
# @
|
113
|
-
# @
|
112
|
+
# See <https://redis.io/commands/sunionstore> for more details.
|
113
|
+
# @parameter destination [Key]
|
114
|
+
# @parameter key [Key]
|
114
115
|
def sunionstore(*arguments)
|
115
116
|
call("SUNIONSTORE", *arguments)
|
116
117
|
end
|
117
118
|
|
118
119
|
# Incrementally iterate Set elements. O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..
|
119
|
-
#
|
120
|
-
# @
|
121
|
-
# @
|
120
|
+
# See <https://redis.io/commands/sscan> for more details.
|
121
|
+
# @parameter key [Key]
|
122
|
+
# @parameter cursor [Integer]
|
122
123
|
def sscan(*arguments)
|
123
124
|
call("SSCAN", *arguments)
|
124
125
|
end
|
@@ -7,34 +7,35 @@
|
|
7
7
|
module Protocol
|
8
8
|
module Redis
|
9
9
|
module Methods
|
10
|
+
# Methods for managing Redis sorted sets.
|
10
11
|
module SortedSets
|
11
12
|
# Remove and return the member with the lowest score from one or more sorted sets, or block until one is available. O(log(N)) with N being the number of elements in the sorted set.
|
12
|
-
#
|
13
|
-
# @
|
14
|
-
# @
|
13
|
+
# See <https://redis.io/commands/bzpopmin> for more details.
|
14
|
+
# @parameter key [Key]
|
15
|
+
# @parameter timeout [Integer]
|
15
16
|
def bzpopmin(*keys, timeout: 0)
|
16
17
|
call("BZPOPMIN", *keys, timeout)
|
17
18
|
end
|
18
19
|
|
19
20
|
# Remove and return the member with the highest score from one or more sorted sets, or block until one is available. O(log(N)) with N being the number of elements in the sorted set.
|
20
|
-
#
|
21
|
-
# @
|
22
|
-
# @
|
21
|
+
# See <https://redis.io/commands/bzpopmax> for more details.
|
22
|
+
# @parameter key [Key]
|
23
|
+
# @parameter timeout [Integer]
|
23
24
|
def bzpopmax(*keys, timeout: 0)
|
24
|
-
call("BZPOPMAX", *keys, timeout
|
25
|
+
call("BZPOPMAX", *keys, timeout)
|
25
26
|
end
|
26
27
|
|
27
28
|
# Add one or more members to a sorted set, or update its score if it already exists. O(log(N)) for each item added, where N is the number of elements in the sorted set.
|
28
|
-
#
|
29
|
-
# @
|
30
|
-
# @
|
31
|
-
# @
|
32
|
-
# @
|
33
|
-
# @
|
34
|
-
# @
|
29
|
+
# See <https://redis.io/commands/zadd> for more details.
|
30
|
+
# @parameter key [Key]
|
31
|
+
# @parameter score [Double]
|
32
|
+
# @parameter member [String]
|
33
|
+
# @parameter others [Array] an array of `score`, `member` elements.
|
34
|
+
# @parameter update [Boolean, nil] If true, only update elements that already exist (never add elements). If false, don't update existing elements (only add new elements).
|
35
|
+
# @parameter change [Boolean] Modify the return value from the number of new elements added,
|
35
36
|
# to the total number of elements changed; changed elements are new elements added
|
36
37
|
# and elements already existing for which the score was updated.
|
37
|
-
# @
|
38
|
+
# @parameter increment [Boolean] When this option is specified ZADD acts like ZINCRBY;
|
38
39
|
# only one score-element pair can be specified in this mode.
|
39
40
|
def zadd(key, score, member, *others, update: nil, change: false, increment: false)
|
40
41
|
arguments = ["ZADD", key]
|
@@ -55,36 +56,36 @@ module Protocol
|
|
55
56
|
end
|
56
57
|
|
57
58
|
# Get the number of members in a sorted set. O(1).
|
58
|
-
#
|
59
|
-
# @
|
59
|
+
# See <https://redis.io/commands/zcard> for more details.
|
60
|
+
# @parameter key [Key]
|
60
61
|
def zcard(key)
|
61
62
|
call("ZCARD", key)
|
62
63
|
end
|
63
64
|
|
64
65
|
# Count the members in a sorted set with scores within the given values. O(log(N)) with N being the number of elements in the sorted set.
|
65
|
-
#
|
66
|
-
# @
|
67
|
-
# @
|
68
|
-
# @
|
66
|
+
# See <https://redis.io/commands/zcount> for more details.
|
67
|
+
# @parameter key [Key]
|
68
|
+
# @parameter min [Double]
|
69
|
+
# @parameter max [Double]
|
69
70
|
def zcount(key, min, max)
|
70
71
|
call("ZCOUNT", key, min, max)
|
71
72
|
end
|
72
73
|
|
73
74
|
# Increment the score of a member in a sorted set. O(log(N)) where N is the number of elements in the sorted set.
|
74
|
-
#
|
75
|
-
# @
|
76
|
-
# @
|
77
|
-
# @
|
75
|
+
# See <https://redis.io/commands/zincrby> for more details.
|
76
|
+
# @parameter key [Key]
|
77
|
+
# @parameter increment [Integer]
|
78
|
+
# @parameter member [String]
|
78
79
|
def zincrby(key, increment, member)
|
79
|
-
call("ZINCRBY", key,
|
80
|
+
call("ZINCRBY", key, increment, member)
|
80
81
|
end
|
81
82
|
|
82
83
|
# Intersect multiple sorted sets and store the resulting sorted set in a new key. O(N*K)+O(M*log(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.
|
83
|
-
#
|
84
|
-
# @
|
85
|
-
# @
|
86
|
-
# @
|
87
|
-
# @
|
84
|
+
# See <https://redis.io/commands/zinterstore> for more details.
|
85
|
+
# @parameter destination [Key]
|
86
|
+
# @parameter keys [Array(Key)]
|
87
|
+
# @parameter weights [Array(Integer)]
|
88
|
+
# @parameter aggregate [Enum] one of sum, min, max.
|
88
89
|
def zinterstore(destination, keys, weights = nil, aggregate: nil)
|
89
90
|
arguments = []
|
90
91
|
|
@@ -105,36 +106,36 @@ module Protocol
|
|
105
106
|
end
|
106
107
|
|
107
108
|
# Count the number of members in a sorted set between a given lexicographical range. O(log(N)) with N being the number of elements in the sorted set.
|
108
|
-
#
|
109
|
-
# @
|
110
|
-
# @
|
111
|
-
# @
|
109
|
+
# See <https://redis.io/commands/zlexcount> for more details.
|
110
|
+
# @parameter key [Key]
|
111
|
+
# @parameter min [String]
|
112
|
+
# @parameter max [String]
|
112
113
|
def zlexcount(key, min, max)
|
113
114
|
call("ZLEXCOUNT", key, min, max)
|
114
115
|
end
|
115
116
|
|
116
117
|
# Remove and return members with the highest scores in a sorted set. O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.
|
117
|
-
#
|
118
|
-
# @
|
119
|
-
# @
|
118
|
+
# See <https://redis.io/commands/zpopmax> for more details.
|
119
|
+
# @parameter key [Key]
|
120
|
+
# @parameter count [Integer]
|
120
121
|
def zpopmax(key, count = 1)
|
121
122
|
call("ZPOPMAX", key, count)
|
122
123
|
end
|
123
124
|
|
124
125
|
# Remove and return members with the lowest scores in a sorted set. O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.
|
125
|
-
#
|
126
|
-
# @
|
127
|
-
# @
|
126
|
+
# See <https://redis.io/commands/zpopmin> for more details.
|
127
|
+
# @parameter key [Key]
|
128
|
+
# @parameter count [Integer]
|
128
129
|
def zpopmin(key, count = 1)
|
129
|
-
call("ZPOPMIN", key, count
|
130
|
+
call("ZPOPMIN", key, count)
|
130
131
|
end
|
131
132
|
|
132
133
|
# Return a range of members in a sorted set, by index. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
|
133
|
-
#
|
134
|
-
# @
|
135
|
-
# @
|
136
|
-
# @
|
137
|
-
# @
|
134
|
+
# See <https://redis.io/commands/zrange> for more details.
|
135
|
+
# @parameter key [Key]
|
136
|
+
# @parameter start [Integer]
|
137
|
+
# @parameter stop [Integer]
|
138
|
+
# @parameter with_scores [Boolean] Return the scores of the elements together with the elements.
|
138
139
|
def zrange(key, start, stop, with_scores: false)
|
139
140
|
arguments = [start, stop]
|
140
141
|
|
@@ -144,11 +145,11 @@ module Protocol
|
|
144
145
|
end
|
145
146
|
|
146
147
|
# Return a range of members in a sorted set, by lexicographical range. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
|
147
|
-
#
|
148
|
-
# @
|
149
|
-
# @
|
150
|
-
# @
|
151
|
-
# @
|
148
|
+
# See <https://redis.io/commands/zrangebylex> for more details.
|
149
|
+
# @parameter key [Key]
|
150
|
+
# @parameter min [String]
|
151
|
+
# @parameter max [String]
|
152
|
+
# @parameter limit [Tuple(offset, count)] Limit the results to the specified `offset` and `count` items.
|
152
153
|
def zrangebylex(key, min, max, limit: nil)
|
153
154
|
if limit
|
154
155
|
arguments = ["LIMIT", *limit]
|
@@ -158,10 +159,10 @@ module Protocol
|
|
158
159
|
end
|
159
160
|
|
160
161
|
# Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
|
161
|
-
#
|
162
|
-
# @
|
163
|
-
# @
|
164
|
-
# @
|
162
|
+
# See <https://redis.io/commands/zrevrangebylex> for more details.
|
163
|
+
# @parameter key [Key]
|
164
|
+
# @parameter max [String]
|
165
|
+
# @parameter min [String]
|
165
166
|
def zrevrangebylex(key, min, max, limit: nil)
|
166
167
|
if limit
|
167
168
|
arguments = ["LIMIT", *limit]
|
@@ -171,125 +172,125 @@ module Protocol
|
|
171
172
|
end
|
172
173
|
|
173
174
|
# Return a range of members in a sorted set, by score. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
|
174
|
-
#
|
175
|
-
# @
|
176
|
-
# @
|
177
|
-
# @
|
178
|
-
# @
|
179
|
-
# @
|
175
|
+
# See <https://redis.io/commands/zrangebyscore> for more details.
|
176
|
+
# @parameter key [Key]
|
177
|
+
# @parameter min [Integer]
|
178
|
+
# @parameter max [Integer]
|
179
|
+
# @parameter with_scores [Boolean] Return the scores of the elements together with the elements.
|
180
|
+
# @parameter limit [Tuple<offset, count>] Limit the results to the specified `offset` and `count` items.
|
180
181
|
#
|
181
182
|
# @example Retrieve the first 10 members with score `>= 0` and `<= 100`
|
182
183
|
# redis.zrangebyscore("zset", "0", "100", limit: [0, 10])
|
183
184
|
def zrangebyscore(key, min, max, with_scores: false, limit: nil)
|
184
185
|
arguments = [min, max]
|
185
186
|
|
186
|
-
arguments.push(
|
187
|
-
arguments.push(
|
187
|
+
arguments.push("WITHSCORES") if with_scores
|
188
|
+
arguments.push("LIMIT", *limit) if limit
|
188
189
|
|
189
|
-
call(
|
190
|
+
call("ZRANGEBYSCORE", key, *arguments)
|
190
191
|
end
|
191
192
|
|
192
193
|
# Determine the index of a member in a sorted set. O(log(N)).
|
193
|
-
#
|
194
|
-
# @
|
195
|
-
# @
|
194
|
+
# See <https://redis.io/commands/zrank> for more details.
|
195
|
+
# @parameter key [Key]
|
196
|
+
# @parameter member [String]
|
196
197
|
def zrank(key, member)
|
197
198
|
call("ZRANK", key, member)
|
198
199
|
end
|
199
200
|
|
200
201
|
# Remove one or more members from a sorted set. O(M*log(N)) with N being the number of elements in the sorted set and M the number of elements to be removed.
|
201
|
-
#
|
202
|
-
# @
|
203
|
-
# @
|
202
|
+
# See <https://redis.io/commands/zrem> for more details.
|
203
|
+
# @parameter key [Key]
|
204
|
+
# @parameter member [String]
|
204
205
|
def zrem(key, member)
|
205
206
|
call("ZREM", key, member)
|
206
207
|
end
|
207
208
|
|
208
209
|
# Remove all members in a sorted set between the given lexicographical range. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
|
209
|
-
#
|
210
|
-
# @
|
211
|
-
# @
|
212
|
-
# @
|
210
|
+
# See <https://redis.io/commands/zremrangebylex> for more details.
|
211
|
+
# @parameter key [Key]
|
212
|
+
# @parameter min [String]
|
213
|
+
# @parameter max [String]
|
213
214
|
def zremrangebylex(key, min, max)
|
214
215
|
call("ZREMRANGEBYLEX", key, min, max)
|
215
216
|
end
|
216
217
|
|
217
218
|
# Remove all members in a sorted set within the given indexes. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
|
218
|
-
#
|
219
|
-
# @
|
220
|
-
# @
|
221
|
-
# @
|
219
|
+
# See <https://redis.io/commands/zremrangebyrank> for more details.
|
220
|
+
# @parameter key [Key]
|
221
|
+
# @parameter start [Integer]
|
222
|
+
# @parameter stop [Integer]
|
222
223
|
def zremrangebyrank(key, start, stop)
|
223
224
|
call("ZREMRANGEBYRANK", key, start, stop)
|
224
225
|
end
|
225
226
|
|
226
227
|
# Remove all members in a sorted set within the given scores. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
|
227
|
-
#
|
228
|
-
# @
|
229
|
-
# @
|
230
|
-
# @
|
228
|
+
# See <https://redis.io/commands/zremrangebyscore> for more details.
|
229
|
+
# @parameter key [Key]
|
230
|
+
# @parameter min [Double]
|
231
|
+
# @parameter max [Double]
|
231
232
|
def zremrangebyscore(key, min, max)
|
232
233
|
call("ZREMRANGEBYSCORE", key, min, max)
|
233
234
|
end
|
234
235
|
|
235
236
|
# Return a range of members in a sorted set, by index, with scores ordered from high to low. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
|
236
|
-
#
|
237
|
-
# @
|
238
|
-
# @
|
239
|
-
# @
|
240
|
-
# @
|
237
|
+
# See <https://redis.io/commands/zrevrange> for more details.
|
238
|
+
# @parameter key [Key]
|
239
|
+
# @parameter start [Integer]
|
240
|
+
# @parameter stop [Integer]
|
241
|
+
# @parameter withscores [Enum]
|
241
242
|
def zrevrange(key, min, max, with_scores: false)
|
242
243
|
arguments = [min, max]
|
243
244
|
|
244
|
-
arguments.push(
|
245
|
+
arguments.push("WITHSCORES") if with_scores
|
245
246
|
|
246
247
|
call("ZREVRANGE", key, *arguments)
|
247
248
|
end
|
248
249
|
|
249
250
|
# Return a range of members in a sorted set, by score, with scores ordered from high to low. O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
|
250
|
-
#
|
251
|
-
# @
|
252
|
-
# @
|
253
|
-
# @
|
254
|
-
# @
|
251
|
+
# See <https://redis.io/commands/zrevrangebyscore> for more details.
|
252
|
+
# @parameter key [Key]
|
253
|
+
# @parameter max [Double]
|
254
|
+
# @parameter min [Double]
|
255
|
+
# @parameter withscores [Enum]
|
255
256
|
def zrevrangebyscore(key, min, max, with_scores: false, limit: nil)
|
256
257
|
arguments = [min, max]
|
257
258
|
|
258
|
-
arguments.push(
|
259
|
-
arguments.push(
|
259
|
+
arguments.push("WITHSCORES") if with_scores
|
260
|
+
arguments.push("LIMIT", *limit) if limit
|
260
261
|
|
261
262
|
call("ZREVRANGEBYSCORE", key, *arguments)
|
262
263
|
end
|
263
264
|
|
264
265
|
# Determine the index of a member in a sorted set, with scores ordered from high to low. O(log(N)).
|
265
|
-
#
|
266
|
-
# @
|
267
|
-
# @
|
266
|
+
# See <https://redis.io/commands/zrevrank> for more details.
|
267
|
+
# @parameter key [Key]
|
268
|
+
# @parameter member [String]
|
268
269
|
def zrevrank(key, member)
|
269
270
|
call("ZREVRANK", key, member)
|
270
271
|
end
|
271
272
|
|
272
273
|
# Get the score associated with the given member in a sorted set. O(1).
|
273
|
-
#
|
274
|
-
# @
|
275
|
-
# @
|
274
|
+
# See <https://redis.io/commands/zscore> for more details.
|
275
|
+
# @parameter key [Key]
|
276
|
+
# @parameter member [String]
|
276
277
|
def zscore(key, member)
|
277
278
|
call("ZSCORE", key, member)
|
278
279
|
end
|
279
280
|
|
280
281
|
# Add multiple sorted sets and store the resulting sorted set in a new key. O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.
|
281
|
-
#
|
282
|
-
# @
|
283
|
-
# @
|
284
|
-
# @
|
282
|
+
# See <https://redis.io/commands/zunionstore> for more details.
|
283
|
+
# @parameter destination [Key]
|
284
|
+
# @parameter numkeys [Integer]
|
285
|
+
# @parameter key [Key]
|
285
286
|
def zunionstore(*arguments)
|
286
287
|
call("ZUNIONSTORE", *arguments)
|
287
288
|
end
|
288
289
|
|
289
290
|
# Incrementally iterate sorted sets elements and associated scores. O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..
|
290
|
-
#
|
291
|
-
# @
|
292
|
-
# @
|
291
|
+
# See <https://redis.io/commands/zscan> for more details.
|
292
|
+
# @parameter key [Key]
|
293
|
+
# @parameter cursor [Integer]
|
293
294
|
def zscan(key, cursor = 0, match: nil, count: nil)
|
294
295
|
arguments = [key, cursor]
|
295
296
|
|