views:

237

answers:

1

I'm trying to use Apache::Session::Memcached in an HTML::Mason project where I'm using MasonX::Request::WithApacheSession to handle my sessions. Unfortunately Apache will not launch when I plug in the Memcached module instead of the MySQL one. My custom handler looks something like this (a few snips here and there):

my $ah = HTML::Mason::ApacheHandler->new (
    comp_root                   =>  $ENV{HTDOCS},
    data_dir                    =>  $data_dir,
    request_class               =>  'MasonX::Request::WithApacheSession',
    session_use_cookie          =>  0,
    args_method                 =>  "mod_perl",
    session_args_param          =>  'session_id',
    session_class               =>  'Apache::Session::Memcached',
    session_Servers             =>  '127.0.0.1:20000',
    session_Readonly            =>  0,
    session_Debug               =>  1,
    session_cookie_domain       =>  $CONF->{global}->{site_name},
    session_cookie_expires      =>  "session",
    session_allow_invalid_id    =>  0,                                          
    );

The problem I'm running into is that the session_* paramaters specific to Memcached are not being passed through to Apache::Session::Memcached like the docs say it should. This results in this error:

The following parameter was passed in the call to HTML::Mason::ApacheHandler->new()
but was not listed in the validation options: session_Servers

Now, I have gone through and swapped all of the 3 upper case arguments to lower case, to no avail. And the docs for Apache::Session::Memcached list them as upper case.

Thanks a ton for any help.

+4  A: 

It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper, following the instructions at http://search.cpan.org/perldoc/Apache::Session::Wrapper#REGISTERING_CLASSES like so (code courtesy Jack M.):

Apache::Session::Wrapper::->RegisterClass(
    'name' => 'Apache::Session::Memcached',
    'required' => [ [ 'Servers' ], ],
    'optional' => [ 'NoRehash', 'Readonly', 'Debug', 'CompressThreshold', ],
);
ysth
You, sir/madam are the man/woman! I've been wracking myself on this one. I don't have the rep to edit your post, but you should throw this in there: Apache::Session::Wrapper->RegisterClass( name => 'Apache::Session::Memcached', required => [ [ 'Servers' ], ], optional => [ 'NoRehash', 'Readonly', 'Debug', 'CompressThreshold', ], );
Jack M.