diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-05-09 19:16:13 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-05-09 19:16:13 +0200 |
commit | 496cdc352852362e6c32a3e2ffbe0cd7cd409cda (patch) | |
tree | 513d274ff9d563c01321f031d3dd43716bb7e9ad /extensions/BzAPI/lib/Resources | |
parent | db7ebb93dda5faa684322d34994b5964b3a4ea85 (diff) | |
download | bugzilla-496cdc352852362e6c32a3e2ffbe0cd7cd409cda.tar.gz bugzilla-496cdc352852362e6c32a3e2ffbe0cd7cd409cda.tar.xz |
Bug 1362151 - Make /bzapi/configuration faster
Diffstat (limited to 'extensions/BzAPI/lib/Resources')
-rw-r--r-- | extensions/BzAPI/lib/Resources/Bugzilla.pm | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/extensions/BzAPI/lib/Resources/Bugzilla.pm b/extensions/BzAPI/lib/Resources/Bugzilla.pm index f39cd29f3..a75a28864 100644 --- a/extensions/BzAPI/lib/Resources/Bugzilla.pm +++ b/extensions/BzAPI/lib/Resources/Bugzilla.pm @@ -59,6 +59,14 @@ sub get_configuration { my $user = Bugzilla->user; my $params = Bugzilla->input_params; + my $can_cache = not exists $params->{product} and not exists $params->{flags}; + my $cache_key = 'bzapi_get_configuration'; + + if ($can_cache) { + my $result = Bugzilla->memcached->get_config({key => $cache_key}); + return $result if defined $result; + } + # Get data from the shadow DB as they don't change very often. Bugzilla->switch_to_shadow_db; @@ -120,11 +128,16 @@ sub get_configuration { my $json; Bugzilla->template->process('config.json.tmpl', $vars, \$json); - my $result = {}; if ($json) { - $result = $self->json->decode($json); + my $result = $self->json->decode($json); + if ($can_cache) { + Bugzilla->memcached->set_config({key => $cache_key, data => $result}); + } + return $result; + } + else { + return {}; } - return $result; } sub get_empty { |