redis_batch 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_batch/queue.rb +5 -10
- data/lib/redis_batch.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ead79130daaa5dd59b528e53f0069b2d7520f2b40001e611ea0e1ce97baadc33
|
4
|
+
data.tar.gz: c63abeed3e5f550ea5ce84356ac4183e9042fec24e12d87c72a6210240846d57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db50906c0891b09654a35d151096df5ebdd89b8fa6b854645d6eba5223840876f16fed94f3299bb12497f59dc92933169b4b67a73fb2609b82df810ab9d195e
|
7
|
+
data.tar.gz: 34ad2d47797b5e5fe7d73da4a300072e8a028ecb6f8a9fb971c42d7b67d5a0ee0cab5bf8e39ed763bc330bd0ec719a5a944e4d6d2df54525e69feeed284c19fb
|
data/lib/redis_batch/queue.rb
CHANGED
@@ -3,6 +3,7 @@ module RedisBatch
|
|
3
3
|
def initialize(namespace = self.class.name)
|
4
4
|
@namespace = namespace
|
5
5
|
@client = Client.instance
|
6
|
+
@client.with { |redis| Functions.function_load(redis) }
|
6
7
|
end
|
7
8
|
|
8
9
|
def add(*items)
|
@@ -19,9 +20,8 @@ module RedisBatch
|
|
19
20
|
|
20
21
|
def abort_all
|
21
22
|
return unless processing?
|
22
|
-
|
23
|
-
|
24
|
-
keys.each do |key|
|
23
|
+
@client.with do |redis|
|
24
|
+
redis.keys("#{@namespace}_takeout_*").each do |key|
|
25
25
|
abort_processing(key, redis)
|
26
26
|
end
|
27
27
|
end
|
@@ -29,9 +29,7 @@ module RedisBatch
|
|
29
29
|
|
30
30
|
def take(count: 1, client: @client)
|
31
31
|
values = client.with do |redis|
|
32
|
-
redis.
|
33
|
-
count.times.map { transaction.lmove(queue_key, take_key, :left, :right) }
|
34
|
-
end
|
32
|
+
redis.call("FCALL", "rb_lmove", 2, queue_key, take_key, count)
|
35
33
|
end
|
36
34
|
yield values
|
37
35
|
client.with { |redis| redis.del(take_key) }
|
@@ -43,10 +41,7 @@ module RedisBatch
|
|
43
41
|
private
|
44
42
|
|
45
43
|
def abort_processing(key, redis)
|
46
|
-
|
47
|
-
redis.multi do |transaction|
|
48
|
-
recover_count.times { transaction.lmove(take_key, queue_key, :right, :left) }
|
49
|
-
end
|
44
|
+
redis.call("FCALL", "rb_lrestore", 2, key, queue_key)
|
50
45
|
end
|
51
46
|
|
52
47
|
def queue_key
|
data/lib/redis_batch.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_batch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Avemark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|