Bug 25292: Flushing L1 on every Z3950 server search

This patch flushes the L1 cache on each Z3950 server search.

There is no need to flush it in init_handler (when the connection is
made), the L1 cache is not accessed (this behaviour goes against what I
expected).

This means each search will fetch values from the
L2 cache (ie memcached) and persist the L1 cache (in Perl
memory cache) until the result are returned (or longer?).

Test plan:
% perl misc/z3950_responder.pl --config-dir=/kohadevbox/koha/etc/z3950
% zoomsh
ZOOM>connect localhost:2100
ZOOM>set databaseName biblios
ZOOM>search x
ZOOM>search x

Between the 2 searches you can modify the value of SearchEngine, you
will notice that the number of hits is different

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-04-27 16:25:32 +02:00
parent 9f03a9e974
commit e466c41304
1 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,8 @@ use Modern::Perl;
use C4::Biblio qw( GetMarcFromKohaField );
use C4::Koha qw( GetAuthorisedValues );
use Koha::Caches;
use Net::Z3950::SimpleServer;
=head1 NAME
@ -178,6 +180,12 @@ Callback that is called when a new search is performed
sub search_handler {
my ( $self, $args ) = @_;
my $SearchEngine = C4::Context->preference('SearchEngine');
# Flushing L1 to make sure the search will be processed using the correct data
Koha::Caches->flush_L1_caches();
$self->init_handler($args)
if $SearchEngine ne C4::Context->preference('SearchEngine');
$args->{HANDLE}->search_handler($args);
}