multi_fetch_fragments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/multi_fetch_fragments.rb +4 -5
  2. metadata +1 -1
@@ -14,18 +14,16 @@ module MultiFetchFragments
14
14
  end
15
15
 
16
16
  result = []
17
- if @options[:cache].present?
18
17
 
18
+ if cache_configured? && @options[:cache].present?
19
19
  keys_to_collection_map = {}
20
- @collection.each do |item|
21
- # debugger
22
20
 
21
+ @collection.each do |item|
23
22
  key = @options[:cache].is_a?(Proc) ? @options[:cache].call(item) : item
24
-
25
23
  expanded_key = ActiveSupport::Cache.expand_cache_key(key)
26
-
27
24
  keys_to_collection_map[expanded_key] = item
28
25
  end
26
+
29
27
  collection_to_keys_map = keys_to_collection_map.invert
30
28
 
31
29
  result_hash = Rails.cache.read_multi(keys_to_collection_map.keys)
@@ -41,6 +39,7 @@ module MultiFetchFragments
41
39
  end
42
40
  end
43
41
 
42
+ # sequentially render any non-cached objects remaining, and cache them
44
43
  if @collection.any?
45
44
  collections_objects = @collection.clone
46
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_fetch_fragments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: