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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 221660e4bbdfdf8d620d9623503e2e1f503052cf
4
- data.tar.gz: 496b11c457fa396fad2a702049737b33b28b0c1d
3
+ metadata.gz: 8fc08d8a3c13c83d3ea708f97f0396eb63bd6240
4
+ data.tar.gz: 18eb7ee9f38372842c409a17c409a138af198f9a
5
5
  SHA512:
6
- metadata.gz: 3a6e2422232cd578907be08ce3e4e480856245799dbdb746174fc5e489007fc96e68133f76b93a1a63cd4f78b142a52f217506b6c4a511cdb5881c8944d7541a
7
- data.tar.gz: 5cccb26f41913573aadd2ebeee600c5aba51bec366b565c43faff5fa3ecdf73f3fe1a6a9dd17e8016956fa4ae823a62731c742a80cb182cb8e6b41b2ae84dc04
6
+ metadata.gz: 7260b7397fa3519e1c4cfc8088cd79134a3f275f9429f876738803a41aa907fb77d30930bda23638f5dab560cd5d84d172e14edff4e9bb70b6a1869325e1ee0c
7
+ data.tar.gz: e897d8b1430944465d0abea5dc3db890b69f62249c47ca86dab5d1f4093fae37e287d85cc77835998304a0bb9bdde3be23d43b86383c805ff2444d50486dffca
@@ -1,3 +1,3 @@
1
1
  module LockAndCacheMsgpack
2
- VERSION = '4.0.7.pre1'
2
+ VERSION = '4.0.7.pre2'
3
3
  end
@@ -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
- raise "only redis for now" unless redis_connection.class.to_s == 'Redis'
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.pre1
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-07 00:00:00.000000000 Z
12
+ date: 2017-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport