From 61dbe014af3fb09189a89d5b0cd8f86ff84764b2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 May 2022 07:36:57 +0200 Subject: [PATCH] Bug 29623: Don't flush the whole L1 cache We shouldn't flush L1 cache completely, only the values related to the circulation rules. It is not correct to update the value of the value we are currently setting (because of the inheritance concept of the circ rules). Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Cache/Memory/Lite.pm | 5 +++++ Koha/CirculationRules.pm | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Koha/Cache/Memory/Lite.pm b/Koha/Cache/Memory/Lite.pm index 74e4115e68..21c6b121d7 100644 --- a/Koha/Cache/Memory/Lite.pm +++ b/Koha/Cache/Memory/Lite.pm @@ -64,6 +64,11 @@ sub clear_from_cache { delete $L1_cache{$key}; } +sub all_keys { + my ( $self ) = @_; + return keys %L1_cache; +} + sub flush { my ( $self ) = @_; %L1_cache = (); diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index b781138fb3..2ddaa00f6b 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -377,10 +377,9 @@ sub set_rule { } my $memory_cache = Koha::Cache::Memory::Lite->get_instance; - my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{}, - $categorycode // q{}, $branchcode // q{}, $itemtype // q{}; - - Koha::Cache::Memory::Lite->flush(); + for my $k ( $memory_cache->all_keys ) { + $memory_cache->clear_from_cache($k) if $k =~ m{^CircRules:}; + } return $rule; } @@ -410,7 +409,6 @@ sub set_rules { push( @$rule_objects, $rule_object ); } - Koha::Cache::Memory::Lite->flush(); return $rule_objects; } -- 2.20.1