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 <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-05-31 07:36:57 +02:00 committed by Tomas Cohen Arazi
parent c373a253e6
commit 61dbe014af
2 changed files with 8 additions and 5 deletions

View file

@ -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 = ();

View file

@ -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;
}