From 84e3286dcd838f37895105bf5985438ed1871e55 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 12 Aug 2025 14:46:38 -0300 Subject: [PATCH] Bug 40636: (follow-up) Cache the calendar object --- C4/Reserves.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 8d467d7d4a6..8b706e500ce 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1070,8 +1070,15 @@ sub CancelExpiredReserves { # FIXME To move to Koha::Holds->search_expired (?) my $holds = Koha::Holds->search($params); + my $cache = Koha::Cache::Memory::Lite->get_instance(); + while ( my $hold = $holds->next ) { - my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); + my $cache_key = sprintf "Calendar_CancelExpiredReserves:%s", $hold->branchcode; + my $calendar = $cache->get_from_cache($cache_key); + if ( !$calendar ) { + $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); + $cache->set_in_cache( $cache_key, $calendar ); + } # Get the actual expiration date for this hold my $expiration_date = $hold->expirationdate || $hold->patron_expiration_date; -- 2.50.1