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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fdd50ceeb6a6661c5b8977e566de0136cc13f0f
4
- data.tar.gz: 00b87565ce88354f9b0c1ae697356f026a920823
3
+ metadata.gz: 3a7645f81f4e7ee4980cdb47c841b853a9fdbe6b
4
+ data.tar.gz: 3c5288088f4f243f7713255676985214bea7db49
5
5
  SHA512:
6
- metadata.gz: 169dd34cdded7eafae43d737b3c047eac8583cafed39d820536a4c0704050aa28d42b0baebe93820643b052ec98ce9b22052087e5b5c7baf77e5e2d68fdbfcfe
7
- data.tar.gz: afdf91150e573ed70b36463cb390e60ce19e0f14405188f23803df94ea4b5adad3cc2ec03a9b8903955c8b9fce896b40939e0e1abb1a322275555fc5adc00258
6
+ metadata.gz: 82aa1f3555638e500820ffabc1cc6d668928acc692c8e720f20d68962e9b9d0c7182d34cd787def3cc14c69feefea8c60e8d9b36deae2d1f3946122a252c009f
7
+ data.tar.gz: 84c281f244ca8b551fd57ba9e48e8193882274e0c3d7abfc12b2a973d3d02bbb109e711cd3446db631f142aa21778be18c7889ff4de0725a53eec824f98a0907
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 2.0.2 / 2015-10-16
2
+
3
+ * Bug fixes (?)
4
+
5
+ * Make sure cached values are valid marshal format (seen in the wild that they're nil)
6
+
7
+ * Enhancements
8
+
9
+ * Use original redlock gem now that it supports extend
10
+
1
11
  2.0.1 / 2015-09-14
2
12
 
3
13
  * Bug fixes
@@ -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(storage.get(digest))
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 storage.get(digest)
158
- else
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
@@ -1,3 +1,3 @@
1
1
  module LockAndCache
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -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 'seamusabshere-redlock'
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'
@@ -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.1
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-09-15 00:00:00.000000000 Z
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: seamusabshere-redlock
42
+ name: redlock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
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: '0'
54
+ version: 0.1.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement