From 1831ea069327ca23fd14375beb1278d7d8be7eb1 Mon Sep 17 00:00:00 2001 From: Robin Sheat Date: Thu, 3 Apr 2014 18:27:12 +1300 Subject: [PATCH] Bug 9967 - expire cached GetAuthorisedValues Adds Memoize::Expire to the caching for GetAuthorisedValues so that updates actually show up in a persistent environment (e.g. Plack) NOTE: This is an experimental patch only. It doesn't work in my testing for no reason I can see. It's for review in case someone can see what silly mistake I made. --- C4/Koha.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 4202957..2db8c5b 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -27,6 +27,7 @@ use C4::Context; use C4::Branch qw(GetBranchesCount); use Koha::DateUtils qw(dt_from_string); use Memoize; +use Memoize::Expire; use DateTime::Format::MySQL; use autouse 'Data::Dumper' => qw(Dumper); use DBI qw(:sql_types); @@ -78,7 +79,9 @@ BEGIN { } # expensive functions -memoize('GetAuthorisedValues'); +tie my %memoize_cache => 'Memoize::Expire', + LIFETIME => 10; +memoize('GetAuthorisedValues', SCALAR_HASH => [HASH => \%memoize_cache]); =head1 NAME @@ -1254,6 +1257,9 @@ Create a new authorised value. sub AddAuthorisedValue { my ($category, $authorised_value, $lib, $lib_opac, $imageurl) = @_; + # clear the memoize cache + flush_cache('AddAuthorisedValue'); + my $dbh = C4::Context->dbh; my $query = qq{ INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) -- 1.8.3.2