|
Lines 81-123
sub new {
Link Here
|
| 81 |
$self->{'timeout'} ||= 0; |
81 |
$self->{'timeout'} ||= 0; |
| 82 |
$self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE} || 'koha'; |
82 |
$self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE} || 'koha'; |
| 83 |
|
83 |
|
| 84 |
if ( can_load( modules => { 'Cache::Memcached::Fast' => undef } ) ) { |
84 |
if ( $self->{'default_type'} eq 'memcached' |
| 85 |
_initialize_memcached($self); |
85 |
&& can_load( modules => { 'Cache::Memcached::Fast' => undef } ) |
| 86 |
if ( $self->{'default_type'} eq 'memcached' |
86 |
&& _initialize_memcached($self) |
| 87 |
&& defined( $self->{'memcached_cache'} ) ) |
87 |
&& defined( $self->{'memcached_cache'} ) ) |
| 88 |
{ |
88 |
{ |
| 89 |
$self->{'cache'} = $self->{'memcached_cache'}; |
89 |
$self->{'cache'} = $self->{'memcached_cache'}; |
| 90 |
} |
|
|
| 91 |
} |
90 |
} |
| 92 |
|
91 |
|
| 93 |
if ( $self->{'default_type'} eq 'fastmmap' |
92 |
if ( $self->{'default_type'} eq 'fastmmap' |
| 94 |
&& defined( $ENV{GATEWAY_INTERFACE} ) |
93 |
&& defined( $ENV{GATEWAY_INTERFACE} ) |
| 95 |
&& can_load( modules => { 'Cache::FastMmap' => undef } ) ) { |
94 |
&& can_load( modules => { 'Cache::FastMmap' => undef } ) |
| 96 |
_initialize_fastmmap($self); |
95 |
&& _initialize_fastmmap($self) |
| 97 |
if ( defined( $self->{'fastmmap_cache'} ) ) |
96 |
&& defined( $self->{'fastmmap_cache'} ) ) |
| 98 |
{ |
97 |
{ |
| 99 |
$self->{'cache'} = $self->{'fastmmap_cache'}; |
98 |
$self->{'cache'} = $self->{'fastmmap_cache'}; |
| 100 |
} |
|
|
| 101 |
} |
99 |
} |
| 102 |
|
100 |
|
| 103 |
if ( can_load( modules => { 'Cache::Memory' => undef, nocache => 1 } ) ) { |
101 |
# Unless memcache or fastmmap has already been picked, use memory_cache |
| 104 |
_initialize_memory($self); |
|
|
| 105 |
if ( $self->{'default_type'} eq 'memory' |
| 106 |
&& defined( $self->{'memory_cache'} ) ) |
| 107 |
{ |
| 108 |
$self->{'cache'} = $self->{'memory_cache'}; |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
# Unless a default has already been picked, we go through in best-to- |
| 113 |
# least-best order, looking for something we can use. fastmmap_cache |
| 114 |
# is excluded because it doesn't support expiry in a useful way. |
| 115 |
unless ( defined( $self->{'cache'} ) ) { |
102 |
unless ( defined( $self->{'cache'} ) ) { |
| 116 |
foreach my $cachemember (qw(memcached_cache memory_cache )) { |
103 |
if ( can_load( modules => { 'Cache::Memory' => undef, nocache => 1 } ) |
| 117 |
if ( defined( $self->{$cachemember} ) ) { |
104 |
&& _initialize_memory($self) ) |
| 118 |
$self->{'cache'} = $self->{$cachemember}; |
105 |
{ |
| 119 |
last; |
106 |
$self->{'cache'} = $self->{'memory_cache'}; |
| 120 |
} |
|
|
| 121 |
} |
107 |
} |
| 122 |
} |
108 |
} |
| 123 |
|
109 |
|
| 124 |
- |
|
|