lock_and_cache_msgpack 4.0.7.pre1 → 4.0.7.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lock_and_cache_msgpack/version.rb +1 -1
- data/lib/lock_and_cache_msgpack.rb +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fc08d8a3c13c83d3ea708f97f0396eb63bd6240
|
4
|
+
data.tar.gz: 18eb7ee9f38372842c409a17c409a138af198f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7260b7397fa3519e1c4cfc8088cd79134a3f275f9429f876738803a41aa907fb77d30930bda23638f5dab560cd5d84d172e14edff4e9bb70b6a1869325e1ee0c
|
7
|
+
data.tar.gz: e897d8b1430944465d0abea5dc3db890b69f62249c47ca86dab5d1f4093fae37e287d85cc77835998304a0bb9bdde3be23d43b86383c805ff2444d50486dffca
|
@@ -23,16 +23,20 @@ module LockAndCacheMsgpack
|
|
23
23
|
|
24
24
|
class TimeoutWaitingForLock < StandardError; end
|
25
25
|
|
26
|
-
# @param redis_connection [Redis] A redis connection to be used for lock and cached value storage
|
26
|
+
# @param redis_connection [Redis || lambda] A redis connection to be used for lock and cached value storage. Lazy evaluated if wrapped in a lambda
|
27
27
|
def LockAndCacheMsgpack.storage=(redis_connection)
|
28
|
-
|
29
|
-
@storage = redis_connection
|
30
|
-
@lock_manager = Redlock::Client.new [redis_connection], retry_count: 1
|
28
|
+
@redis_connection = redis_connection
|
31
29
|
end
|
32
30
|
|
33
31
|
# @return [Redis] The redis connection used for lock and cached value storage
|
34
32
|
def LockAndCacheMsgpack.storage
|
35
|
-
@storage
|
33
|
+
@storage ||=
|
34
|
+
begin
|
35
|
+
raise "only redis for now" unless redis_connection.class.to_s == 'Redis'
|
36
|
+
connection = @redis_connection.respond_to?(:call) ? @redis_connection.call : @redis_connection
|
37
|
+
@lock_manager = Redlock::Client.new [connection], retry_count: 1
|
38
|
+
connection
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
# @param logger [Logger] A logger.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lock_and_cache_msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.7.
|
4
|
+
version: 4.0.7.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-08-
|
12
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|