Lines 18-24
package C4::Context;
Link Here
|
18 |
|
18 |
|
19 |
use strict; |
19 |
use strict; |
20 |
use warnings; |
20 |
use warnings; |
21 |
use vars qw($VERSION $AUTOLOAD $context @context_stack $servers $memcached $ismemcached); |
21 |
use vars qw($VERSION $AUTOLOAD $context @context_stack $memcached $ismemcached); |
22 |
|
22 |
|
23 |
BEGIN { |
23 |
BEGIN { |
24 |
if ($ENV{'HTTP_USER_AGENT'}) { |
24 |
if ($ENV{'HTTP_USER_AGENT'}) { |
Lines 79-101
BEGIN {
Link Here
|
79 |
} |
79 |
} |
80 |
} # else there is no browser to send fatals to! |
80 |
} # else there is no browser to send fatals to! |
81 |
|
81 |
|
|
|
82 |
$VERSION = '3.07.00.049'; |
83 |
} |
84 |
|
85 |
UNITCHECK { |
82 |
# Check if there are memcached servers set |
86 |
# Check if there are memcached servers set |
83 |
$servers = $ENV{'MEMCACHED_SERVERS'}; |
87 |
if ($ENV{'MEMCACHED_SERVERS'}) { |
84 |
if ($servers) { |
|
|
85 |
# Load required libraries and create the memcached object |
88 |
# Load required libraries and create the memcached object |
86 |
require Cache::Memcached; |
89 |
require Cache::Memcached; |
87 |
$memcached = Cache::Memcached->new({ |
90 |
$memcached = Cache::Memcached->new(memcached_params()); |
88 |
servers => [ $servers ], |
|
|
89 |
debug => 0, |
90 |
compress_threshold => 10_000, |
91 |
expire_time => 600, |
92 |
namespace => $ENV{'MEMCACHED_NAMESPACE'} || 'koha' |
93 |
}); |
94 |
# Verify memcached available (set a variable and test the output) |
91 |
# Verify memcached available (set a variable and test the output) |
95 |
$ismemcached = $memcached->set('ismemcached','1'); |
92 |
$ismemcached = $memcached->set('ismemcached','1'); |
96 |
} |
93 |
} |
97 |
|
|
|
98 |
$VERSION = '3.07.00.049'; |
99 |
} |
94 |
} |
100 |
|
95 |
|
101 |
use DBI; |
96 |
use DBI; |
Lines 293-298
sub memcached {
Link Here
|
293 |
} |
288 |
} |
294 |
} |
289 |
} |
295 |
|
290 |
|
|
|
291 |
=head2 memcached_params |
292 |
|
293 |
Return a hashref containing the memcached parameters in a |
294 |
form suitable for initializing a new C<Cache::Memcached> |
295 |
object. Caller is responsible for verifying that connection |
296 |
parameters work. |
297 |
|
298 |
=cut |
299 |
|
300 |
sub memcached_params { |
301 |
return { |
302 |
servers => [ $ENV{'MEMCACHED_SERVERS'} ], |
303 |
namespace => $ENV{'MEMCACHED_NAMESPACE'} || 'koha', |
304 |
debug => 0, |
305 |
expire_time => 600, |
306 |
compress_threshold => 10_000, |
307 |
}; |
308 |
} |
309 |
|
296 |
# db_scheme2dbi |
310 |
# db_scheme2dbi |
297 |
# Translates the full text name of a database into de appropiate dbi name |
311 |
# Translates the full text name of a database into de appropiate dbi name |
298 |
# |
312 |
# |