lock_and_cache 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/lib/lock_and_cache.rb +6 -5
- data/lib/lock_and_cache/version.rb +1 -1
- data/lock_and_cache.gemspec +1 -1
- data/spec/lock_and_cache_spec.rb +11 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a7645f81f4e7ee4980cdb47c841b853a9fdbe6b
|
4
|
+
data.tar.gz: 3c5288088f4f243f7713255676985214bea7db49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82aa1f3555638e500820ffabc1cc6d668928acc692c8e720f20d68962e9b9d0c7182d34cd787def3cc14c69feefea8c60e8d9b36deae2d1f3946122a252c009f
|
7
|
+
data.tar.gz: 84c281f244ca8b551fd57ba9e48e8193882274e0c3d7abfc12b2a973d3d02bbb109e711cd3446db631f142aa21778be18c7889ff4de0725a53eec824f98a0907
|
data/CHANGELOG
CHANGED
data/lib/lock_and_cache.rb
CHANGED
@@ -136,8 +136,8 @@ module LockAndCache
|
|
136
136
|
digest = key.digest
|
137
137
|
storage = LockAndCache.storage or raise("must set LockAndCache.storage=[Redis]")
|
138
138
|
Thread.exclusive { $stderr.puts "[lock_and_cache] A1 #{key.debug} #{Base64.encode64(digest).strip} #{Digest::SHA1.hexdigest digest}" } if debug
|
139
|
-
if storage.exists digest
|
140
|
-
return ::Marshal.load(
|
139
|
+
if storage.exists(digest) and (existing = storage.get(digest)).is_a?(String)
|
140
|
+
return ::Marshal.load(existing)
|
141
141
|
end
|
142
142
|
Thread.exclusive { $stderr.puts "[lock_and_cache] B1 #{key.debug} #{Base64.encode64(digest).strip} #{Digest::SHA1.hexdigest digest}" } if debug
|
143
143
|
retval = nil
|
@@ -152,10 +152,11 @@ module LockAndCache
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
Thread.exclusive { $stderr.puts "[lock_and_cache] D1 #{key.debug} #{Base64.encode64(digest).strip} #{Digest::SHA1.hexdigest digest}" } if debug
|
155
|
-
if storage.exists digest
|
155
|
+
if storage.exists(digest) and (existing = storage.get(digest)).is_a?(String)
|
156
156
|
Thread.exclusive { $stderr.puts "[lock_and_cache] E1 #{key.debug} #{Base64.encode64(digest).strip} #{Digest::SHA1.hexdigest digest}" } if debug
|
157
|
-
retval = ::Marshal.load
|
158
|
-
|
157
|
+
retval = ::Marshal.load existing
|
158
|
+
end
|
159
|
+
unless retval
|
159
160
|
Thread.exclusive { $stderr.puts "[lock_and_cache] F1 #{key.debug} #{Base64.encode64(digest).strip} #{Digest::SHA1.hexdigest digest}" } if debug
|
160
161
|
done = false
|
161
162
|
begin
|
data/lock_and_cache.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency 'activesupport'
|
22
22
|
spec.add_runtime_dependency 'redis'
|
23
23
|
# temporary until https://github.com/leandromoreira/redlock-rb/pull/20 is merged
|
24
|
-
spec.add_runtime_dependency '
|
24
|
+
spec.add_runtime_dependency 'redlock', '>=0.1.3'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'pry'
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
data/spec/lock_and_cache_spec.rb
CHANGED
@@ -15,6 +15,12 @@ class Foo
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def click_null
|
19
|
+
lock_and_cache do
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
def click_exp
|
19
25
|
lock_and_cache(expires: 1, foo: :bar) do
|
20
26
|
@count_exp += 1
|
@@ -111,6 +117,11 @@ describe LockAndCache do
|
|
111
117
|
sleep 2
|
112
118
|
expect(foo.click_exp).to eq(2)
|
113
119
|
end
|
120
|
+
|
121
|
+
it "can cache null" do
|
122
|
+
expect(foo.click_null).to eq(nil)
|
123
|
+
expect(foo.click_null).to eq(nil)
|
124
|
+
end
|
114
125
|
end
|
115
126
|
|
116
127
|
describe "locking" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lock_and_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: redlock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|