From 101801f9c4150bafd55bc0eecfc2de3972888e38 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 22 Mar 2019 08:51:05 +0000 Subject: [PATCH] Bug 17385: (QA follow-up) Add caching Performance: We should add caching in CustomXSLTExportList. Note: This resolves the lack of an intranet test in the former patch too. Test plan: Run t/db_dependent/XSLT.t Signed-off-by: Marcel de Rooy Signed-off-by: David Nind --- C4/XSLT.pm | 8 ++++++++ t/db_dependent/XSLT.t | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 194fbcec89f..0415e5b3682 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -23,6 +23,7 @@ package C4::XSLT; use Modern::Perl; use base 'Exporter'; +use Koha::Caches; use Koha::XSLT::Base; use XML::LibXML; use Encode; @@ -486,6 +487,12 @@ sub CustomXSLTExportList { my $opac = shift; # opac (1) vs intranet (0) return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/; + # Check the cache first + my $cache = Koha::Caches->get_instance; + my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra'; + my $cached_val = $cache->get_from_cache($key); + return $cached_val if $cached_val; + my @tabFiles; my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . @@ -522,6 +529,7 @@ sub CustomXSLTExportList { push @tabFiles, \%row; } } + $cache->set_in_cache( $key, [ @tabFiles ] ); return \@tabFiles; } 1; diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 601178d43c6..1ce78b12ae6 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -1,4 +1,3 @@ -original #!/usr/bin/perl # This file is part of Koha. -- 2.43.0