Skip to content

Commit 23a1888

Browse files
committed
Remove the deprecated queue and commit methods
1 parent 4b24589 commit 23a1888

File tree

4 files changed

+1
-103
lines changed

4 files changed

+1
-103
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Unreleased 5.0.0
44

5+
- Removed the deprecated `queue` and `commit` methods. Use `pipelined` instead.
56
- Removed the deprecated `pipelined` and `multi` signature. Commands now MUST be called on the block argument, not the original redis instance.
67
- Removed `Redis.current`. You shouldn't assume there is a single global Redis connection, use a connection pool instead,
78
and libaries using Redis should accept a Redis instance (or connection pool) as a config. E.g. `MyLibrary.redis = Redis.new(...)`.

lib/redis.rb

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,47 +90,6 @@ def with
9090
yield self
9191
end
9292

93-
# @deprecated Queues a command for pipelining.
94-
#
95-
# Commands in the queue are executed with the Redis#commit method.
96-
#
97-
# See http://redis.io/topics/pipelining for more details.
98-
#
99-
def queue(*command)
100-
::Redis.deprecate!(
101-
"Redis#queue is deprecated and will be removed in Redis 5.0.0. Use Redis#pipelined instead." \
102-
"(called from: #{caller(1, 1).first})"
103-
)
104-
105-
synchronize do
106-
@queue[Thread.current.object_id] << command
107-
end
108-
end
109-
110-
# @deprecated Sends all commands in the queue.
111-
#
112-
# See http://redis.io/topics/pipelining for more details.
113-
#
114-
def commit
115-
::Redis.deprecate!(
116-
"Redis#commit is deprecated and will be removed in Redis 5.0.0. Use Redis#pipelined instead. " \
117-
"(called from: #{Kernel.caller(1, 1).first})"
118-
)
119-
120-
synchronize do |client|
121-
begin
122-
pipeline = Pipeline.new(client)
123-
@queue[Thread.current.object_id].each do |command|
124-
pipeline.call(command)
125-
end
126-
127-
client.call_pipelined(pipeline)
128-
ensure
129-
@queue.delete(Thread.current.object_id)
130-
end
131-
end
132-
end
133-
13493
def _client
13594
@client
13695
end

test/redis/client_test.rb

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,6 @@ def test_call_raise
2626
end
2727
end
2828

29-
def test_queue_commit
30-
r.queue("SET", "foo", "bar")
31-
r.queue("GET", "foo")
32-
result = r.commit
33-
34-
assert_equal result, ["OK", "bar"]
35-
end
36-
37-
def test_commit_raise
38-
r.queue("SET", "foo", "bar")
39-
r.queue("INCR")
40-
41-
assert_raises(Redis::CommandError) do
42-
r.commit
43-
end
44-
end
45-
46-
def test_queue_after_error
47-
r.queue("SET", "foo", "bar")
48-
r.queue("INCR")
49-
50-
assert_raises(Redis::CommandError) do
51-
r.commit
52-
end
53-
54-
r.queue("SET", "foo", "bar")
55-
r.queue("INCR", "baz")
56-
result = r.commit
57-
58-
assert_equal result, ["OK", 1]
59-
end
60-
6129
def test_client_with_custom_connector
6230
custom_connector = Class.new(Redis::Client::Connector) do
6331
def resolve

test/redis/thread_safety_test.rb

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,5 @@ def test_thread_safety
2727
assert_equal ["1"], @foos.uniq
2828
assert_equal ["2"], @bars.uniq
2929
end
30-
31-
def test_thread_safety_queue_commit
32-
redis = Redis.new(OPTIONS)
33-
redis.set "foo", 1
34-
redis.set "bar", 2
35-
36-
sample = 100
37-
38-
t1 = Thread.new do
39-
sample.times do
40-
r.queue("get", "foo")
41-
end
42-
43-
@foos = r.commit
44-
end
45-
46-
t2 = Thread.new do
47-
sample.times do
48-
r.queue("get", "bar")
49-
end
50-
51-
@bars = r.commit
52-
end
53-
54-
t1.join
55-
t2.join
56-
57-
assert_equal ["1"], @foos.uniq
58-
assert_equal ["2"], @bars.uniq
59-
end
6030
end
6131
end

0 commit comments

Comments
 (0)