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