Bug 40636: (follow-up) Cache the calendar object

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 47f0aab19f)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Tomas Cohen Arazi 2025-08-12 14:46:38 -03:00 committed by Paul Derscheid
parent 9c90d072c3
commit c24826b4a5
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 8 additions and 1 deletions

View File

@ -1068,8 +1068,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;