Commit da0347e9 authored by Dylan Hardison's avatar Dylan Hardison

Bug 1251208 - Bugzilla->request_cache() can be faster

r=dkl,a=dylan without breaking stuff this time.
parent 0cac98df
...@@ -682,43 +682,21 @@ sub local_timezone { ...@@ -682,43 +682,21 @@ sub local_timezone {
||= DateTime::TimeZone->new(name => 'local'); ||= DateTime::TimeZone->new(name => 'local');
} }
# This creates the request cache for non-mod_perl installations. my $request_cache = Bugzilla::Install::Util::_cache();
# This is identical to Install::Util::_cache so that things loaded
# into Install::Util::_cache during installation can be read out sub request_cache { return $request_cache }
# of request_cache later in installation.
our $_request_cache = $Bugzilla::Install::Util::_cache;
sub request_cache {
if ($ENV{MOD_PERL}) {
require Apache2::RequestUtil;
# Sometimes (for example, during mod_perl.pl), the request
# object isn't available, and we should use $_request_cache instead.
my $request = eval { Apache2::RequestUtil->request };
return $_request_cache if !$request;
return $request->pnotes();
}
return $_request_cache;
}
sub clear_request_cache { sub clear_request_cache {
$_request_cache = {}; %$request_cache = ();
if ($ENV{MOD_PERL}) {
require Apache2::RequestUtil;
my $request = eval { Apache2::RequestUtil->request };
if ($request) {
my $pnotes = $request->pnotes;
delete @$pnotes{(keys %$pnotes)};
}
}
} }
# This is a per-process cache. Under mod_cgi it's identical to the # 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 # request_cache. When using mod_perl, items in this cache live until the
# worker process is terminated. # worker process is terminated.
our $_process_cache = {}; my $process_cache = {};
sub process_cache { sub process_cache {
return $_process_cache; return $process_cache;
} }
# This is a memcached wrapper, which provides cross-process and cross-system # This is a memcached wrapper, which provides cross-process and cross-system
......
...@@ -651,15 +651,8 @@ sub prevent_windows_dialog_boxes { ...@@ -651,15 +651,8 @@ sub prevent_windows_dialog_boxes {
# This is like request_cache, but it's used only by installation code # This is like request_cache, but it's used only by installation code
# for checksetup.pl and things like that. # for checksetup.pl and things like that.
our $_cache = {}; my $_cache = {};
sub _cache { sub _cache { return $_cache; }
# If the normal request_cache is available (which happens any time
# after the requirements phase) then we should use that.
if (eval { Bugzilla->request_cache; }) {
return Bugzilla->request_cache;
}
return $_cache;
}
############################### ###############################
# Copied from Bugzilla::Util # # Copied from Bugzilla::Util #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment