From 7ffd1602a005310978a8b1e08efc7397826b4668 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 5 Dec 2018 16:39:02 -0300 Subject: [PATCH] Bug 21955: Remove Cache::Memory as fallback for L2 cache If Plack is running with several workers we must not use Cache::Memory as L2 cache. If a value is set from a worker, it will not be available from other workers as the Cache::Memory instance is not shared (of course!) Moreover we now have Koha::Cache::Memory::Lite that does the same job, so we should not expect performance regressions by removing it. See also the email sent to koha-devel for more info http://lists.koha-community.org/pipermail/koha-devel/2018-December/045004.html Signed-off-by: Martin Renvoize Signed-off-by: Julian Maurice Signed-off-by: Nick Clemens (cherry picked from commit 4bf033c6d6b2a8bf4d5597b3fdf6355fb7060b60) Signed-off-by: Martin Renvoize (cherry picked from commit 6039f64e53172a046c5b579271df7cf434b20e81) --- C4/Installer/PerlDependencies.pm | 5 ----- Koha/Cache.pm | 36 -------------------------------- 2 files changed, 41 deletions(-) diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index 670585ba31..4a2c60540c 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -267,11 +267,6 @@ our $PERL_DEPS = { 'required' => '0', 'min_ver' => '1.34' }, - 'Cache::Memory' => { - 'usage' => 'Caching', - 'required' => '0', - 'min_ver' => '2.04' - }, 'Net::LDAP::Filter' => { 'usage' => 'LDAP Interface Feature', 'required' => '0', diff --git a/Koha/Cache.pm b/Koha/Cache.pm index be478fa4fb..cf77257825 100644 --- a/Koha/Cache.pm +++ b/Koha/Cache.pm @@ -103,15 +103,6 @@ sub new { $self->{'cache'} = $self->{'fastmmap_cache'}; } - # Unless memcache or fastmmap has already been picked, use memory_cache - unless ( defined( $self->{'cache'} ) ) { - if ( can_load( modules => { 'Cache::Memory' => undef } ) - && _initialize_memory($self) ) - { - $self->{'cache'} = $self->{'memory_cache'}; - } - } - $ENV{DEBUG} && carp "Selected caching system: " . ($self->{'cache'} // 'none'); return @@ -177,33 +168,6 @@ sub _initialize_fastmmap { return $self; } -sub _initialize_memory { - my ($self) = @_; - - # Default cache time for memory is _always_ short unless it's specially - # defined, to allow it to work reliably in a persistent environment. - my $cache = Cache::Memory->new( - 'namespace' => $self->{'namespace'}, - 'default_expires' => "$self->{'timeout'} sec" || "10 sec", - ); - $self->{'memory_cache'} = $cache; - # Memory cache can't handle complex types for some reason, so we use its - # freeze and thaw functions. - $self->{ref($cache) . '_set'} = sub { - my ($key, $val, $exp) = @_; - # Refer to set_expiry in Cache::Entry for why we do this 'sec' thing. - $exp = "$exp sec" if defined $exp; - # Because we need to use freeze, it must be a reference type. - $cache->freeze($key, [$val], $exp); - }; - $self->{ref($cache) . '_get'} = sub { - my $res = $cache->thaw(shift); - return unless defined $res; - return $res->[0]; - }; - return $self; -} - =head2 is_cache_active Routine that checks whether or not a default caching method is active on this -- 2.39.5