From ead56def261db6da1610e1367e2ff69cb92ba088 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Sat, 2 Apr 2011 22:36:42 -0400 Subject: [PATCH] bug 4865: Enable session storage in Memcached Note: this requires CGI::Session::Driver::memcached to be installed Signed-off-by: Galen Charlton Signed-off-by: Chris Cormack --- C4/Auth.pm | 17 +++++++++++++++-- .../en/modules/admin/preferences/admin.pref | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index cecf8f8deb..35c083889d 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -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'}); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 3ef972b6f6..a2ecc5c81e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -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 -- 2.39.5