From 287c121caf666119b430fd3114bfd97527048356 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 07c4991499..62df52b8f0 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -29,6 +29,7 @@ use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure ); use Koha::AuthorisedValues; use Koha::ItemTypes; use Koha::RecordProcessor; +use Koha::Caches; use Koha::XSLT::Base; use Koha::Libraries; use Koha::Recalls; @@ -423,6 +424,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') . @@ -459,6 +466,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 3c7b312075..5f79b35b13 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.34.1