diff options
author | Byron Jones <bjones@mozilla.com> | 2012-10-04 18:49:53 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-10-04 18:49:53 +0200 |
commit | f7d1f7b803a9e89be4407d102a48eddd1708e103 (patch) | |
tree | 80424188c2e3e1e735c125046cfceca53d9d1016 | |
parent | c204c9ebc89dd923378257730309ff4a9722b684 (diff) | |
download | bugzilla-f7d1f7b803a9e89be4407d102a48eddd1708e103.tar.gz bugzilla-f7d1f7b803a9e89be4407d102a48eddd1708e103.tar.xz |
Bug 797883: Adds a Bugzilla->process_cache
r=LpSolit, a=LpSolit
-rw-r--r-- | Bugzilla.pm | 12 | ||||
-rw-r--r-- | Bugzilla/Template.pm | 13 |
2 files changed, 16 insertions, 9 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm index f956f5a0e..6c86fb0fc 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -271,8 +271,7 @@ sub input_params { our $_localconfig; sub localconfig { - $_localconfig ||= read_localconfig(); - return $_localconfig; + return $_[0]->process_cache->{localconfig} ||= read_localconfig(); } sub params { @@ -643,6 +642,15 @@ sub request_cache { return $_request_cache; } +# This is a per-process cache. Under mod_cgi it's identical to the +# request_cache. When using mod_perl, items in this cache live until the +# worker process is terminated. +our $_process_cache = {}; + +sub process_cache { + return $_process_cache; +} + # Private methods # Per-process cleanup. Note that this is a plain subroutine, not a method, diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 6685a7431..f6796dfc7 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -41,10 +41,6 @@ use constant FORMAT_3_SIZE => [19,28,28]; use constant FORMAT_DOUBLE => '%19s %-55s'; use constant FORMAT_2_SIZE => [19,55]; -# Use a per-process provider to cache compiled templates in memory across -# requests. -our %shared_providers; - # Pseudo-constant. sub SAFE_URL_REGEXP { my $safe_protocols = join('|', SAFE_PROTOCOLS); @@ -982,9 +978,12 @@ sub create { 'default_authorizer' => new Bugzilla::Auth(), }, }; + # Use a per-process provider to cache compiled templates in memory across + # requests. my $provider_key = join(':', @{ $config->{INCLUDE_PATH} }); - $shared_providers{$provider_key} ||= Template::Provider->new($config); - $config->{LOAD_TEMPLATES} = [ $shared_providers{$provider_key} ]; + my $shared_providers = Bugzilla->process_cache->{shared_providers} ||= {}; + $shared_providers->{$provider_key} ||= Template::Provider->new($config); + $config->{LOAD_TEMPLATES} = [ $shared_providers->{$provider_key} ]; local $Template::Config::CONTEXT = 'Bugzilla::Template::Context'; @@ -1051,7 +1050,7 @@ sub precompile_templates { } # Clear out the cached Provider object - undef %shared_providers; + Bugzilla->process_cache->{shared_providers} = undef; } # Under mod_perl, we look for templates using the absolute path of the |