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 +4 -4
- data/README.md +7 -0
- data/lib/autobots/helpers/caching.rb +6 -0
- data/lib/autobots/version.rb +1 -1
- data/test/caching_test.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5db85a281108b8978c09c975c64f0c761aeee784
|
4
|
+
data.tar.gz: 080aa1be51c836e09ee1f96827e0b6f64ba8fc2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/autobots/version.rb
CHANGED
data/test/caching_test.rb
CHANGED
@@ -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.
|
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-
|
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
|