Skip to content

Commit 591c4aa

Browse files
committed
Eager load Journey Formatter cache
This cache is used when url_for is called without a named route (ie. when it's called with hash options). Eager loading avoids building the cache on the first call and potentially allows the memory to be shared via CoW on forking servers.
1 parent 939fd3b commit 591c4aa

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

actionpack/lib/action_dispatch/journey/formatter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def clear
104104
@cache = nil
105105
end
106106

107+
def eager_load!
108+
cache
109+
nil
110+
end
111+
107112
private
108113
def extract_parameterized_parts(route, options, recall)
109114
parameterized_parts = recall.merge(options)

actionpack/lib/action_dispatch/routing/route_set.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def initialize(config = DEFAULT_CONFIG)
386386
def eager_load!
387387
router.eager_load!
388388
routes.each(&:eager_load!)
389+
formatter.eager_load!
389390
nil
390391
end
391392

0 commit comments

Comments
 (0)