seamusabshere-redlock 1.0.1 → 1.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/redlock/client.rb +8 -2
- data/lib/redlock/testing.rb +9 -0
- data/lib/redlock/version.rb +1 -1
- 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: 3c0063b411459eb636e0c6babf77c6f18e8f98d3
|
4
|
+
data.tar.gz: 0d59f5bb456803d41a4270210f1da4d5a9f96b55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c9793d807ee82c229a264467975bd406ed95027a7d5c38b530bf19866a7673e1a16de840c05bbb5cac27f2cff9fb7c5ebc8d48b77ab80cdc8070a7055f10923
|
7
|
+
data.tar.gz: e9e993e0d69f3dfbd6e2b7047255087d9c241b88c1d1c5384da0269090625f9e5cb1872fd56687a7b05c2532e638ab06265db600f26b8f251240b9c865e86043
|
data/lib/redlock/client.rb
CHANGED
@@ -84,8 +84,7 @@ module Redlock
|
|
84
84
|
@redis = Redis.new(connection)
|
85
85
|
end
|
86
86
|
|
87
|
-
|
88
|
-
@lock_script_sha = @redis.script(:load, LOCK_SCRIPT)
|
87
|
+
load_scripts
|
89
88
|
end
|
90
89
|
|
91
90
|
def lock(resource, val, ttl)
|
@@ -97,6 +96,13 @@ module Redlock
|
|
97
96
|
rescue
|
98
97
|
# Nothing to do, unlocking is just a best-effort attempt.
|
99
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def load_scripts
|
103
|
+
@unlock_script_sha = @redis.script(:load, UNLOCK_SCRIPT)
|
104
|
+
@lock_script_sha = @redis.script(:load, LOCK_SCRIPT)
|
105
|
+
end
|
100
106
|
end
|
101
107
|
|
102
108
|
def try_lock_instances(resource, ttl, extend)
|
data/lib/redlock/testing.rb
CHANGED
@@ -23,5 +23,14 @@ module Redlock
|
|
23
23
|
def unlock(lock_info)
|
24
24
|
unlock_without_testing lock_info unless @testing_mode == :bypass
|
25
25
|
end
|
26
|
+
|
27
|
+
class RedisInstance
|
28
|
+
def load_scripts
|
29
|
+
if @redis.respond_to?(:script)
|
30
|
+
@unlock_script_sha = @redis.script(:load, UNLOCK_SCRIPT)
|
31
|
+
@lock_script_sha = @redis.script(:load, LOCK_SCRIPT)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
data/lib/redlock/version.rb
CHANGED