autobots 0.2.1 → 0.2.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: c09d3a52f075f9dbe81a701a194accac21f4f7af
4
- data.tar.gz: 0c1733a2c3849202f8928b0b85f3b3420dcc3923
3
+ metadata.gz: 5db85a281108b8978c09c975c64f0c761aeee784
4
+ data.tar.gz: 080aa1be51c836e09ee1f96827e0b6f64ba8fc2c
5
5
  SHA512:
6
- metadata.gz: 08f178e8886f9fd654e6852bd83fd9f11e46df46ac776378232e364ce5a3afa74063f36e5ff1ce2c20eb0214b118b8b79aa7942e77ce293d98d1f1d42a35ff1a
7
- data.tar.gz: b62ee5b7c4390ac766ff35f3902ded5f757224dfb34cabe31d4c99fd2b2df7ce9f0770fb0917230ab75aaf85b71b3f82032f9dc56ff398dd6c3a17cfa11c2c82
6
+ metadata.gz: 41647ba8a1ae084d96659d09ee437662c05f6fa249ce444dd67fe41e4cd00668896d66ead2cfeb922142e0cfa64cf5b422e448a944542918d00071771af0c9f3
7
+ data.tar.gz: 2b901b28f07e4b19b360bd6c0ff09200dce7bf987ddc08b503c4e2fb1042a8a79d008e24640cbc11b522cac95cb750387d12e179583f639283120ff5e62e9359
data/README.md CHANGED
@@ -140,6 +140,13 @@ By default, we use each resource's `cache_key` implementation. You can provide y
140
140
  }
141
141
  })
142
142
 
143
+ If you want to wipe the old cache and force a reload, you can pass in the :force_reload option
144
+
145
+ assembler = ProjectAssembler.new(project_ids, {
146
+ cache: cache,
147
+ force_reload: true
148
+ })
149
+
143
150
 
144
151
  ## Contributing
145
152
 
@@ -26,6 +26,12 @@ module Autobots
26
26
  acc
27
27
  end
28
28
 
29
+ if options[:force_reload]
30
+ identifiers.each do |key, _|
31
+ cache.delete key
32
+ end
33
+ end
34
+
29
35
  # misses: { key => obj }
30
36
  @data = BulkCacheFetcher.new(cache).fetch(identifiers) do |misses|
31
37
  roll_out(misses.values)
@@ -1,3 +1,3 @@
1
1
  module Autobots
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -24,4 +24,25 @@ class CachingTest < ActiveSupport::TestCase
24
24
  assert_equal expected_data, data
25
25
  end
26
26
 
27
+ def test_can_force_cache_clear
28
+ cache = ActiveSupport::Cache::MemoryStore.new
29
+ projects = Project.all
30
+ assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache)
31
+
32
+ # warming cache
33
+ expected_data = nil
34
+ assert_queries 3 do
35
+ expected_data = assembler.data
36
+ end
37
+
38
+ projects = Project.all
39
+ assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache, force_reload: true)
40
+ data = nil
41
+ assert_queries 3 do
42
+ data = assembler.data
43
+ end
44
+
45
+ assert_equal expected_data, data
46
+ end
47
+
27
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Ching
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bulk_cache_fetcher