Bug 16105: Do not initialize the memory cache if not needed
Cache::Memory is loaded and Koha::Cache::_initialize_memory is called
even if a memcached cache has been correctly initialize, it does not
make sense.
It should only be initialize if needed.
Test plan:
Correctly configure a memcache server and confirm that the memory cache
is not initialize.
Do not configure correctly a memcache server and confirm that the cache
system default on Cache::Memory
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit 2026be47fd)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
parent
353bd00653
commit
33a3f9df09
|
|
@ -81,43 +81,29 @@ sub new {
|
|||
$self->{'timeout'} ||= 0;
|
||||
$self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE} || 'koha';
|
||||
|
||||
if ( can_load( modules => { 'Cache::Memcached::Fast' => undef } ) ) {
|
||||
_initialize_memcached($self);
|
||||
if ( $self->{'default_type'} eq 'memcached'
|
||||
&& defined( $self->{'memcached_cache'} ) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'memcached_cache'};
|
||||
}
|
||||
if ( $self->{'default_type'} eq 'memcached'
|
||||
&& can_load( modules => { 'Cache::Memcached::Fast' => undef } )
|
||||
&& _initialize_memcached($self)
|
||||
&& defined( $self->{'memcached_cache'} ) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'memcached_cache'};
|
||||
}
|
||||
|
||||
if ( $self->{'default_type'} eq 'fastmmap'
|
||||
&& defined( $ENV{GATEWAY_INTERFACE} )
|
||||
&& can_load( modules => { 'Cache::FastMmap' => undef } ) ) {
|
||||
_initialize_fastmmap($self);
|
||||
if ( defined( $self->{'fastmmap_cache'} ) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'fastmmap_cache'};
|
||||
}
|
||||
&& can_load( modules => { 'Cache::FastMmap' => undef } )
|
||||
&& _initialize_fastmmap($self)
|
||||
&& defined( $self->{'fastmmap_cache'} ) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'fastmmap_cache'};
|
||||
}
|
||||
|
||||
if ( can_load( modules => { 'Cache::Memory' => undef } ) ) {
|
||||
_initialize_memory($self);
|
||||
if ( $self->{'default_type'} eq 'memory'
|
||||
&& defined( $self->{'memory_cache'} ) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'memory_cache'};
|
||||
}
|
||||
}
|
||||
|
||||
# Unless a default has already been picked, we go through in best-to-
|
||||
# least-best order, looking for something we can use. fastmmap_cache
|
||||
# is excluded because it doesn't support expiry in a useful way.
|
||||
# Unless memcache or fastmmap has already been picked, use memory_cache
|
||||
unless ( defined( $self->{'cache'} ) ) {
|
||||
foreach my $cachemember (qw(memcached_cache memory_cache )) {
|
||||
if ( defined( $self->{$cachemember} ) ) {
|
||||
$self->{'cache'} = $self->{$cachemember};
|
||||
last;
|
||||
}
|
||||
if ( can_load( modules => { 'Cache::Memory' => undef } )
|
||||
&& _initialize_memory($self) )
|
||||
{
|
||||
$self->{'cache'} = $self->{'memory_cache'};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue