Catalyst::Plugin::Session::Store::TestMemcached - Automatic creation of test Memcached instance
In your Catalyst application class:
package MyApp::Web; our $VERSION = '0.01'; use Moose; use Catalyst qw/ Session Session::Store::TestMemcached Session::State::Cookie /; extends 'Catalyst'; __PACKAGE__->setup; __PACKAGE__->meta->make_immutable;
Later in a controller:
package MyApp::Controller::Root; use Moose; use MooseX::MethodAttributes; extends 'Catalyst::Controller'; sub welcome : Path(welcome) { my ($self, $ctx) = @_; my $count = ++$ctx->session->{count}; $ctx->session(count => $count); $ctx->res->body("Welcome to Catalyst: $count"); } __PACKAGE__->meta->make_immutable;
This uses Test::Memcached to make an application scoped instance of a memcached server, so that if you want to test using memcached as a store for sessions you don't need to run it in a separate job.
This is probably useful only for testing and prototypes. Additionally, many people suggest using memcached, which is not really a persistent data store, for sessions is not a great practice. As you wish!
John Napiorkowski email:jjnapiork@cpan.org
Catalyst::Plugin::Session::Store::Memcached, Catalyst::Plugin::Session, Catalyst, Test::Memcached
Copyright 2012, John Napiorkowski email:jjnapiork@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Plugin::Session::Store::TestMemcached, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Session::Store::TestMemcached
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Session::Store::TestMemcached
For more information on module installation, please visit the detailed CPAN module installation guide.