Skip to content

Commit

Permalink
Eager load Journey Formatter cache
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhawthorn committed Nov 8, 2023
1 parent 939fd3b commit 591c4aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions actionpack/lib/action_dispatch/journey/formatter.rb
Expand Up @@ -104,6 +104,11 @@ def clear
@cache = nil
end

def eager_load!
cache
nil
end

private
def extract_parameterized_parts(route, options, recall)
parameterized_parts = recall.merge(options)
Expand Down
1 change: 1 addition & 0 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -386,6 +386,7 @@ def initialize(config = DEFAULT_CONFIG)
def eager_load!
router.eager_load!
routes.each(&:eager_load!)
formatter.eager_load!
nil
end

Expand Down

0 comments on commit 591c4aa

Please sign in to comment.