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 Signed-off-by: emlam <emily.lamancusa@montgomerycountymd.gov> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
a0ec93d84f
commit
55dc8573c7
1 changed files with 11 additions and 4 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue