redis_queue 0.6.0 → 0.6.1
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/lib/redis_queue.rb +16 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec321ee8d7b2c72ec76a0061f8676bf7a54f215f
|
4
|
+
data.tar.gz: 6ab9ed9ead9ce2470728e0424a6b7ff96413adff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e815a7e4272d0a79cb8ec709fa5bb663923983227e5a35bbe271c515fa96a496bd792c66cfdef8ed73c337c10e583ef24ea4029d453ec4931b2e5a58df8ddbf
|
7
|
+
data.tar.gz: 4cbee5cb67aa31e53f4a1ea90cc1da7f6593e4b0687fa29b48f32ac6132e5da2bc0109397fd4fc0d8e44a9222d2109367c6ea53b0110e27bd4d817b86ca46b50
|
data/lib/redis_queue.rb
CHANGED
@@ -12,6 +12,16 @@ class RedisQueue
|
|
12
12
|
|
13
13
|
SCRIPTS = {
|
14
14
|
push: PUSH_CODE,
|
15
|
+
nonblpop: ''"
|
16
|
+
local message = ''
|
17
|
+
while message == '' do
|
18
|
+
message = redis.call('lpop', ARGV[1])
|
19
|
+
end
|
20
|
+
if message then
|
21
|
+
redis.call('sadd', ARGV[1]..'_in_use', message)
|
22
|
+
end
|
23
|
+
return message
|
24
|
+
"'',
|
15
25
|
repush: ''"
|
16
26
|
#{PUSH_CODE}
|
17
27
|
redis.call('srem', ARGV[1]..'_in_use', ARGV[2])
|
@@ -44,10 +54,9 @@ class RedisQueue
|
|
44
54
|
end
|
45
55
|
|
46
56
|
def pop(block: true)
|
47
|
-
|
57
|
+
return nonblpop unless block
|
48
58
|
begin
|
49
|
-
message = @redis_blocking.run { |redis| redis.
|
50
|
-
message = message.last if command == :blpop
|
59
|
+
message = @redis_blocking.run { |redis| redis.blpop(@id) }.last
|
51
60
|
end while message == ''
|
52
61
|
@redis.run { |redis| redis.sadd "#{@id}_in_use", message } if message
|
53
62
|
message
|
@@ -148,6 +157,10 @@ class RedisQueue
|
|
148
157
|
|
149
158
|
private
|
150
159
|
|
160
|
+
def nonblpop
|
161
|
+
script :nonblpop, @id
|
162
|
+
end
|
163
|
+
|
151
164
|
def load_scripts
|
152
165
|
@scripts = {}
|
153
166
|
@redis.run do |redis|
|