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.
This commit is contained in:
John Hawthorn 2023-11-07 20:07:23 -08:00
parent 939fd3bc41
commit 591c4aa1ea
2 changed files with 6 additions and 0 deletions

@ -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)

@ -386,6 +386,7 @@ def initialize(config = DEFAULT_CONFIG)
def eager_load!
router.eager_load!
routes.each(&:eager_load!)
formatter.eager_load!
nil
end