From 2ea79b98787f16d612c36b687953f04222149576 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 Content-Type: text/plain; charset=utf-8 Signed-off-by: Paul Derscheid Signed-off-by: Marcel de Rooy --- C4/Reserves.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9a200b2dac..84957f1179 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.39.5