redis 4.4.0 → 4.6.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
- data/CHANGELOG.md +72 -0
- data/README.md +10 -10
- data/lib/redis/client.rb +26 -11
- data/lib/redis/cluster/command.rb +4 -6
- data/lib/redis/cluster/command_loader.rb +6 -7
- data/lib/redis/cluster/node.rb +12 -0
- data/lib/redis/cluster.rb +24 -0
- data/lib/redis/commands/bitmaps.rb +63 -0
- data/lib/redis/commands/cluster.rb +45 -0
- data/lib/redis/commands/connection.rb +58 -0
- data/lib/redis/commands/geo.rb +84 -0
- data/lib/redis/commands/hashes.rb +251 -0
- data/lib/redis/commands/hyper_log_log.rb +37 -0
- data/lib/redis/commands/keys.rb +411 -0
- data/lib/redis/commands/lists.rb +289 -0
- data/lib/redis/commands/pubsub.rb +72 -0
- data/lib/redis/commands/scripting.rb +114 -0
- data/lib/redis/commands/server.rb +188 -0
- data/lib/redis/commands/sets.rb +207 -0
- data/lib/redis/commands/sorted_sets.rb +804 -0
- data/lib/redis/commands/streams.rb +382 -0
- data/lib/redis/commands/strings.rb +313 -0
- data/lib/redis/commands/transactions.rb +92 -0
- data/lib/redis/commands.rb +242 -0
- data/lib/redis/connection/command_helper.rb +2 -0
- data/lib/redis/connection/hiredis.rb +3 -2
- data/lib/redis/connection/ruby.rb +13 -9
- data/lib/redis/connection/synchrony.rb +10 -8
- data/lib/redis/connection.rb +1 -1
- data/lib/redis/distributed.rb +86 -9
- data/lib/redis/pipeline.rb +95 -2
- data/lib/redis/version.rb +1 -1
- data/lib/redis.rb +133 -3484
- metadata +22 -5
data/lib/redis/pipeline.rb
CHANGED
@@ -1,7 +1,70 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "delegate"
|
4
|
+
|
3
5
|
class Redis
|
6
|
+
class PipelinedConnection
|
7
|
+
def initialize(pipeline)
|
8
|
+
@pipeline = pipeline
|
9
|
+
end
|
10
|
+
|
11
|
+
include Commands
|
12
|
+
|
13
|
+
def db
|
14
|
+
@pipeline.db
|
15
|
+
end
|
16
|
+
|
17
|
+
def db=(db)
|
18
|
+
@pipeline.db = db
|
19
|
+
end
|
20
|
+
|
21
|
+
def pipelined
|
22
|
+
yield self
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def synchronize
|
28
|
+
yield self
|
29
|
+
end
|
30
|
+
|
31
|
+
def send_command(command, &block)
|
32
|
+
@pipeline.call(command, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def send_blocking_command(command, timeout, &block)
|
36
|
+
@pipeline.call_with_timeout(command, timeout, &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
4
40
|
class Pipeline
|
41
|
+
REDIS_INTERNAL_PATH = File.expand_path("..", __dir__).freeze
|
42
|
+
# Redis use MonitorMixin#synchronize and this class use DelegateClass which we want to filter out.
|
43
|
+
# Both are in the stdlib so we can simply filter the entire stdlib out.
|
44
|
+
STDLIB_PATH = File.expand_path("..", MonitorMixin.instance_method(:synchronize).source_location.first).freeze
|
45
|
+
|
46
|
+
class << self
|
47
|
+
def deprecation_warning(method, caller_locations) # :nodoc:
|
48
|
+
callsite = caller_locations.find { |l| !l.path.start_with?(REDIS_INTERNAL_PATH, STDLIB_PATH) }
|
49
|
+
callsite ||= caller_locations.last # The caller_locations should be large enough, but just in case.
|
50
|
+
::Redis.deprecate! <<~MESSAGE
|
51
|
+
Pipelining commands on a Redis instance is deprecated and will be removed in Redis 5.0.0.
|
52
|
+
|
53
|
+
redis.#{method} do
|
54
|
+
redis.get("key")
|
55
|
+
end
|
56
|
+
|
57
|
+
should be replaced by
|
58
|
+
|
59
|
+
redis.#{method} do |pipeline|
|
60
|
+
pipeline.get("key")
|
61
|
+
end
|
62
|
+
|
63
|
+
(called from #{callsite}}
|
64
|
+
MESSAGE
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
5
68
|
attr_accessor :db
|
6
69
|
attr_reader :client
|
7
70
|
|
@@ -124,6 +187,36 @@ class Redis
|
|
124
187
|
end
|
125
188
|
end
|
126
189
|
|
190
|
+
class DeprecatedPipeline < DelegateClass(Pipeline)
|
191
|
+
def initialize(pipeline)
|
192
|
+
super(pipeline)
|
193
|
+
@deprecation_displayed = false
|
194
|
+
end
|
195
|
+
|
196
|
+
def __getobj__
|
197
|
+
unless @deprecation_displayed
|
198
|
+
Pipeline.deprecation_warning("pipelined", Kernel.caller_locations(1, 10))
|
199
|
+
@deprecation_displayed = true
|
200
|
+
end
|
201
|
+
@delegate_dc_obj
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
class DeprecatedMulti < DelegateClass(Pipeline::Multi)
|
206
|
+
def initialize(pipeline)
|
207
|
+
super(pipeline)
|
208
|
+
@deprecation_displayed = false
|
209
|
+
end
|
210
|
+
|
211
|
+
def __getobj__
|
212
|
+
unless @deprecation_displayed
|
213
|
+
Pipeline.deprecation_warning("multi", Kernel.caller_locations(1, 10))
|
214
|
+
@deprecation_displayed = true
|
215
|
+
end
|
216
|
+
@delegate_dc_obj
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
127
220
|
class FutureNotReady < RuntimeError
|
128
221
|
def initialize
|
129
222
|
super("Value will be available once the pipeline executes.")
|
@@ -143,11 +236,11 @@ class Redis
|
|
143
236
|
end
|
144
237
|
|
145
238
|
def ==(_other)
|
146
|
-
message = +"The methods == and != are deprecated for Redis::Future and will be removed in
|
239
|
+
message = +"The methods == and != are deprecated for Redis::Future and will be removed in 5.0.0"
|
147
240
|
message << " - You probably meant to call .value == or .value !="
|
148
241
|
message << " (#{::Kernel.caller(1, 1).first})\n"
|
149
242
|
|
150
|
-
::
|
243
|
+
::Redis.deprecate!(message)
|
151
244
|
|
152
245
|
super
|
153
246
|
end
|
data/lib/redis/version.rb
CHANGED