[Koha-patches] [PATCH] Enable session storage in Memcached
Chris Cormack
chrisc at catalyst.net.nz
Tue Jun 8 13:06:15 CEST 2010
Note: this requires CGI::Session::Driver::memcached to be installed
---
C4/Auth.pm | 17 +++++++++++++++--
.../prog/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 4f76ea6..f2e3949 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
@@ -1349,6 +1359,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 069ea9d..c08e3ef 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
@@ -70,6 +70,7 @@ Administration:
mysql: in the MySQL database.
Pg: in the PostgreSQL database (not supported).
tmp: as temporary files.
+ memcached: in a memcached server.
-
- Control staff access to pages within Koha based on
- pref: GranularPermissions
--
1.6.3.3
More information about the Koha-patches
mailing list