From: Liam Whalen Date: Fri, 25 Sep 2015 18:19:43 +0000 (-0700) Subject: LP#1499537 Moved storage of kpac.xml to hash X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fldw%2FLP1499537_kpac_xml_caching;p=working%2FEvergreen.git LP#1499537 Moved storage of kpac.xml to hash In order to increase performance, the check for the cached version of kpac.xml has been restored and modified to use a global hash rather than a global scalar. Signed-off-by: Liam Whalen --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index 0a0f8dc11c..260914c140 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -7,7 +7,7 @@ use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Application::AppUtils; use OpenILS::Utils::CStoreEditor qw/:funcs/; my $U = 'OpenILS::Application::AppUtils'; -my $kpac_config; +my %kpac_config; # ----------------------------------------------------------------------------- # Override our parent's load() sub so we can do kpac-specific path routing. @@ -238,29 +238,32 @@ sub load_kpac_config { $self->apache->log->error("KPacConfigFile required!"); return; } + + if (!$kpac_config{$path}) { - $kpac_config = XMLin( - $path, - KeyAttr => ['id'], - ForceArray => ['layout', 'page', 'cell'], - NormaliseSpace => 2 - ); + $kpac_config{$path} = XMLin( + $path, + KeyAttr => ['id'], + ForceArray => ['layout', 'page', 'cell'], + NormaliseSpace => 2 + ); + } my $ou = $ctx->{physical_loc} || $self->_get_search_lib; my $layout; # Search up the org tree to find the nearest config for the context org unit while (my $org = $ctx->{get_aou}->($ou)) { - ($layout) = grep {$_->{owner} eq $org->id} @{$kpac_config->{layout}}; + ($layout) = grep {$_->{owner} eq $org->id} @{$kpac_config{$path}->{layout}}; last if $layout; $ou = $org->parent_ou; } $ctx->{kpac_layout} = $layout; - $ctx->{kpac_config} = $kpac_config; + $ctx->{kpac_config} = $kpac_config{$path}; $ctx->{kpac_root} = $ctx->{base_path} . "/kpac"; $ctx->{home_page} = $ctx->{proto} . '://' . $ctx->{hostname} . $ctx->{kpac_root} . "/home"; - $ctx->{global_search_filter} = $kpac_config->{global_filter}; + $ctx->{global_search_filter} = $kpac_config{$path}->{global_filter}; }