lock_and_cache 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b4c2d0489b674d6efd75d4a368fda53ffc7f869
4
- data.tar.gz: ededebda48c306638c3d19c2047f1fff49dc00fc
3
+ metadata.gz: 19f9d5d8d273859b3802392c2c716bf2a60b897f
4
+ data.tar.gz: 45727c9b74dd4fb11b6e8e6fa9dd2655ae01f231
5
5
  SHA512:
6
- metadata.gz: 4837ba9ea728c9b330e489aebd0cd0d0f13ddbb7d99259ccfd958edbb9bafb4f58ac1e7f2dd37f3686d03be9d823b6a970df21b313306fff88f75a6b6c0b2a82
7
- data.tar.gz: 2f07f2ec076d96bc6f6eb7febb2538daf1e3af305ba2947c227a1da6ff586d8cd7cfc56fb86418f6b3b353e518712d86a6dfe00496c759d46f3c864b40a2437e
6
+ metadata.gz: f27d00caceafde847297680ca8e12c81d2d1f006ff93c50a1f711117d75bd0a1a73a6d118caf29a9cafe7adf5084d6ab66843a2af70e57fec2bd4323a228ad15
7
+ data.tar.gz: 7b66cc2ed3a4f4da75dfec0b22afb299163e999f5791cb59ecc931883910412d7a34845790d6abf2e9e4654b3e5821d2deb3098df1796e090d5a71364dda8161
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 2.1.1 / 2015-10-26
2
+
3
+ * Bug fixes
4
+
5
+ * Blow up if you try to use standalone mode without a key
6
+
1
7
  2.1.0 / 2015-10-26
2
8
 
3
9
  * Enhancements
data/README.md CHANGED
@@ -15,6 +15,31 @@ Lock and cache using redis!
15
15
 
16
16
  We use [`lock_and_cache`](https://rubygems.org/gems/lock_and_cache) for [big data-driven marketing at Faraday](http://faraday.io).
17
17
 
18
+ ## TOC
19
+
20
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
21
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
22
+
23
+
24
+ - [Theory](#theory)
25
+ - [Practice](#practice)
26
+ - [Locking](#locking)
27
+ - [Caching](#caching)
28
+ - [Standalone mode](#standalone-mode)
29
+ - [Context mode](#context-mode)
30
+ - [Special features](#special-features)
31
+ - [Locking of course!](#locking-of-course)
32
+ - [Heartbeat](#heartbeat)
33
+ - [Context mode](#context-mode-1)
34
+ - [nil_expires](#nil_expires)
35
+ - [Tunables](#tunables)
36
+ - [Few dependencies](#few-dependencies)
37
+ - [Wishlist](#wishlist)
38
+ - [Contributing](#contributing)
39
+ - [Copyright](#copyright)
40
+
41
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
42
+
18
43
  ## Theory
19
44
 
20
45
  `lock_and_cache`...
@@ -54,6 +54,7 @@ module LockAndCache
54
54
  # @note A single hash arg is treated as a cached key. `LockAndCache.lock_and_cache(foo: :bar, expires: 100)` will be treated as a cache key of `foo: :bar, expires: 100` (which is probably wrong!!!). `LockAndCache.lock_and_cache({foo: :bar}, expires: 100)` will be treated as a cache key of `foo: :bar` and options `expires: 100`. This is the opposite of context mode and is true because we don't have any context to set the cache key from otherwise.
55
55
  def LockAndCache.lock_and_cache(*key_parts_and_options, &blk)
56
56
  options = (key_parts_and_options.last.is_a?(Hash) && key_parts_and_options.length > 1) ? key_parts_and_options.pop : {}
57
+ raise "need a cache key" unless key_parts_and_options.length > 0
57
58
  key = LockAndCache::Key.new key_parts_and_options
58
59
  action = LockAndCache::Action.new key, options, blk
59
60
  action.perform
@@ -1,3 +1,3 @@
1
1
  module LockAndCache
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
@@ -287,6 +287,14 @@ describe LockAndCache do
287
287
  expect(count).to eq(2)
288
288
  end
289
289
 
290
+ it "requires a key" do
291
+ expect do
292
+ LockAndCache.lock_and_cache do
293
+ raise "this won't happen"
294
+ end
295
+ end.to raise_error(/need/)
296
+ end
297
+
290
298
  it 'allows clearing' do
291
299
  count = 0
292
300
  expect(LockAndCache.lock_and_cache('hello') { count += 1 }).to eq(1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_and_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere