From 6fa9d1f2e8cd0d4caccc153c2eff5cbe3cb82301 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Wed, 2 Mar 2016 18:31:51 +0200 Subject: [PATCH] Bug 15958 - ZOOM/Zebra-connection cache flushing When writing tests related to searching, When searching the local index repeatedly, changes in the index are not applied to the search results if the results always return the same records. This is due to ZOOM caching the results. This feature adds a ZOOM::Connection flushing subroutine to get rid of old caches. --- C4/Context.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/C4/Context.pm b/C4/Context.pm index e5a4ab3..7a5eb77 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -782,6 +782,21 @@ sub _new_Zconn { return $Zconn; } +=head2 flushZconns + +Destroys all Zebra connections flushing their caches. + +=cut + +sub flushZconns { + my @ZconnKeys = keys%{$context->{"Zconn"}} if ref($context->{"Zconn"}) eq 'HASH'; + foreach my $key (@ZconnKeys) { + my $Zc = $context->{"Zconn"}->{$key}; + $Zc->destroy(); + delete $context->{"Zconn"}->{$key}; + } +} + # _new_dbh # Internal helper function (not a method!). This creates a new # database connection from the data given in the current context, and -- 1.9.1