Bugzilla – Attachment 128472 Details for
Bug 29454
Stash itemtypes in plugin objects to reduce DB calls
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29454: Use Koha Cache Memory Lite to stash itemtype descriptions for template plugin
Bug-29454-Use-Koha-Cache-Memory-Lite-to-stash-item.patch (text/plain), 1.84 KB, created by
Nick Clemens
on 2021-12-13 14:48:48 UTC
(
hide
)
Description:
Bug 29454: Use Koha Cache Memory Lite to stash itemtype descriptions for template plugin
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2021-12-13 14:48:48 UTC
Size:
1.84 KB
patch
obsolete
>From d081265d2a2d6061ff69345c4df4f434450e5608 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 13 Dec 2021 14:44:18 +0000 >Subject: [PATCH] Bug 29454: Use Koha Cache Memory Lite to stash itemtype > descriptions for template plugin > >To test: >1 - Add 1000 items to a record, of varying item types >2 - Bring up the details page >3 - Note time to load >4 - Apply patch >5 - Reload page and compare to previous >6 - Confirm information is correct >7 - Confirm some performance benefit >--- > Koha/Template/Plugin/ItemTypes.pm | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > >diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm >index 5b3cf1edeb..f863bde23c 100644 >--- a/Koha/Template/Plugin/ItemTypes.pm >+++ b/Koha/Template/Plugin/ItemTypes.pm >@@ -22,15 +22,24 @@ use Modern::Perl; > use Template::Plugin; > use base qw( Template::Plugin ); > >+use Koha::Cache::Memory::Lite; > use Koha::ItemTypes; > > sub GetDescription { > my ( $self, $itemtypecode, $want_parent ) = @_; >+ >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = $want_parent ? "Itemtype_parent_description:".$itemtypecode : "Itemtype_description:" . $itemtypecode; >+ my $cached = $memory_cache->get_from_cache($cache_key); >+ return $cached if $cached; >+ > my $itemtype = Koha::ItemTypes->find( $itemtypecode ); > return q{} unless $itemtype; > my $parent; > $parent = $itemtype->parent if $want_parent; >- return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; >+ my $description = $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; >+ $memory_cache->set_in_cache( $cache_key, $description ); >+ return $description; > } > > sub Get { >-- >2.20.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 29454
:
127515
|
127520
|
128472
|
136077
|
136078
|
136090
|
136091
|
136149
|
136150
|
136151