Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TZInfo.eager_load! #129

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/tzinfo.rb
Expand Up @@ -3,6 +3,15 @@

# The top level module for TZInfo.
module TZInfo
class << self
# Force all timezone data to be loaded immediately. This is desirable in
# production environments to improve Copy-on-Write performance and to
# avoid flushing the constant cache every time a new timezone is accessed.
def eager_load!
Timezone.all.each(&:eager_load!)
nil
end
end
end

# Object#untaint is a deprecated no-op in Ruby >= 2.7 and will be removed in
Expand Down
5 changes: 5 additions & 0 deletions lib/tzinfo/timezone_proxy.rb
Expand Up @@ -72,6 +72,11 @@ def self._load(data)
TimezoneProxy.new(data)
end

def eager_load!
real_timezone
nil
end

private

# Returns the real {Timezone} instance being proxied.
Expand Down