multi_fetch_fragments 0.0.2 → 0.0.3
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.
- data/lib/multi_fetch_fragments.rb +4 -5
- 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
|
|