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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c574b14f3f0fa1579a35bd5813674c43f518995
4
- data.tar.gz: f4d5d32692ae8ff6d3ce51e6182edb99f27f2ec8
3
+ metadata.gz: 3c0063b411459eb636e0c6babf77c6f18e8f98d3
4
+ data.tar.gz: 0d59f5bb456803d41a4270210f1da4d5a9f96b55
5
5
  SHA512:
6
- metadata.gz: 9e428989a3ce86571b3de822eaf1e192ed9759f7c6a4253fe6fa2b177922572c79d01a4b245c0fec5adfc6d205bbd584006dbd500c6ebcff8616c2cc3578671c
7
- data.tar.gz: 652d211789b071fc02b220266ab974f03bf53a53c79b9aa39642e0a79619a21dfaa5d9adfecc16337e5a7303c5b49c23daefdca12021bc3f8d7455015f7fba14
6
+ metadata.gz: 8c9793d807ee82c229a264467975bd406ed95027a7d5c38b530bf19866a7673e1a16de840c05bbb5cac27f2cff9fb7c5ebc8d48b77ab80cdc8070a7055f10923
7
+ data.tar.gz: e9e993e0d69f3dfbd6e2b7047255087d9c241b88c1d1c5384da0269090625f9e5cb1872fd56687a7b05c2532e638ab06265db600f26b8f251240b9c865e86043
@@ -84,8 +84,7 @@ module Redlock
84
84
  @redis = Redis.new(connection)
85
85
  end
86
86
 
87
- @unlock_script_sha = @redis.script(:load, UNLOCK_SCRIPT)
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Redlock
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seamusabshere-redlock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Moreira