Bugzilla – Attachment 128446 Details for
Bug 26587
Cache libraries in Branches TT plugin to improve performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26587: Use Koha::Cache::Memory::Lite
Bug-26587-Use-KohaCacheMemoryLite.patch (text/plain), 1.67 KB, created by
Jonathan Druart
on 2021-12-13 11:25:49 UTC
(
hide
)
Description:
Bug 26587: Use Koha::Cache::Memory::Lite
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-12-13 11:25:49 UTC
Size:
1.67 KB
patch
obsolete
>From 871a1080c2d9485d802487fec80dc67e475affed Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 13 Dec 2021 12:25:29 +0100 >Subject: [PATCH] Bug 26587: Use Koha::Cache::Memory::Lite > >--- > Koha/Template/Plugin/Branches.pm | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index c4f552a71fb..a4db89b61ce 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -25,26 +25,22 @@ use base qw( Template::Plugin ); > > use C4::Koha; > use C4::Context; >+use Koha::Cache::Memory::Lite; > use Koha::Libraries; > >-sub new { >- my ($self) = shift; >- my (@params) = @_; >- $self = $self->SUPER::new(@params); >- #Initialize a cache of libraries for lookups of names,urls etc. >- $self->{libraries} = {}; >- >- return $self; >-} >- > sub GetName { > my ( $self, $branchcode ) = @_; > >- unless (exists $self->{libraries}->{$branchcode} ){ >- my $l = Koha::Libraries->find($branchcode); >- $self->{libraries}->{$branchcode} = $l if $l; >- } >- return $self->{libraries}->{$branchcode} ? $self->{libraries}->{$branchcode}->branchname : q{}; >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = "Library_branchname:" . $branchcode; >+ my $cached = $memory_cache->get_from_cache($cache_key); >+ return $cached if $cached; >+ >+ my $l = Koha::Libraries->find($branchcode); >+ >+ my $branchname = $l ? $l->branchname : q{}; >+ $memory_cache->set_in_cache( $cache_key, $branchname ); >+ return $branchname; > } > > sub GetLoggedInBranchcode { >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26587
:
120298
|
120299
|
120300
|
120311
|
120401
|
120402
|
127411
|
128446
|
128470
|
128471