bug 4865: Enable session storage in Memcached

Note: this requires CGI::Session::Driver::memcached to be installed

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Chris Cormack 2011-04-02 22:36:42 -04:00
parent f0b17df29a
commit ead56def26
2 changed files with 16 additions and 2 deletions

View File

@ -34,7 +34,7 @@ use C4::VirtualShelves;
use POSIX qw/strftime/;
# use utf8;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $servers $memcached);
BEGIN {
$VERSION = 3.02; # set version for version checking
@ -54,7 +54,17 @@ BEGIN {
require C4::Auth_with_cas; # no import
import C4::Auth_with_cas qw(checkpw_cas login_cas logout_cas login_cas_url);
}
$servers = C4::Context->config('memcached_servers');
$memcached;
if ($servers) {
require Cache::Memcached;
$memcached = Cache::Memcached->new({
servers => [ $servers ],
debug => 0,
compress_threshold => 10_000,
namespace => C4::Context->config('memcached_namespace') || 'koha',
});
}
}
=head1 NAME
@ -1346,6 +1356,9 @@ sub get_session {
elsif ($storage_method eq 'Pg') {
$session = new CGI::Session("driver:PostgreSQL;serializer:yaml;id:md5", $sessionID, {Handle=>$dbh});
}
elsif ($storage_method eq 'memcached' && $servers){
$session = new CGI::Session("driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => $memcached } );
}
else {
# catch all defaults to tmp should work on all systems
$session = new CGI::Session("driver:File;serializer:yaml;id:md5", $sessionID, {Directory=>'/tmp'});

View File

@ -69,6 +69,7 @@ Administration:
mysql: in the MySQL database.
Pg: in the PostgreSQL database (not supported).
tmp: as temporary files.
memcached: in a memcached server.
-
- pref: IndependantBranches
default: 0