Bugzilla – Attachment 149295 Details for
Bug 33447
Add caching to Biblio->pickup_locations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33447: Add Cache to Biblio->pickup_locations
Bug-33447-Add-Cache-to-Biblio-pickuplocations.patch (text/plain), 2.14 KB, created by
Nick Clemens (kidclamp)
on 2023-04-07 21:47:36 UTC
(
hide
)
Description:
Bug 33447: Add Cache to Biblio->pickup_locations
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-04-07 21:47:36 UTC
Size:
2.14 KB
patch
obsolete
>From 3fecdf1d6dfba5680556273066cd3d348560dec1 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 7 Apr 2023 21:08:30 +0000 >Subject: [PATCH] Bug 33447: Add Cache to Biblio->pickup_locations > >This is going to have the most effect on records with large numbers of items >held by the same library, serial records and the like > >To test: >1 - Add 500 items to a biblio by select myltiple copies on the add item page >2 - Place a hold via the API and note response time, I found ~3-5 seconds >3 - Apply patch >4 - Restart all >5 - Place hold using api again >6 - Note improved response time, less than 1/2 a second in my tests >--- > Koha/Biblio.pm | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 8c453a83ef..a94665ddc8 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -35,6 +35,7 @@ use Koha::ArticleRequests; > use Koha::Biblio::Metadatas; > use Koha::Biblio::ItemGroups; > use Koha::Biblioitems; >+use Koha::Cache::Memory::Lite; > use Koha::Checkouts; > use Koha::CirculationRules; > use Koha::Item::Transfer::Limits; >@@ -267,11 +268,17 @@ sub pickup_locations { > > my $patron = $params->{patron}; > >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); > my @pickup_locations; >- foreach my $item_of_bib ( $self->items->as_list ) { >- push @pickup_locations, >- $item_of_bib->pickup_locations( { patron => $patron } ) >- ->_resultset->get_column('branchcode')->all; >+ foreach my $item ( $self->items->as_list ) { >+ my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s", >+ $item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ; >+ my $item_pickup_locations = $memory_cache->get_from_cache( $cache_key ); >+ unless( $item_pickup_locations ){ >+ @{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all; >+ $memory_cache->set_in_cache( $cache_key, $item_pickup_locations ); >+ } >+ push @pickup_locations, @{ $item_pickup_locations } > } > > return Koha::Libraries->search( >-- >2.30.2
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 33447
:
149295
|
149296
|
149389
|
149390
|
149790
|
149791
|
149792
|
149968
|
149981
|
149982