| Catalyst-Plugin-Session-Store-Memcached documentation | Contained in the Catalyst-Plugin-Session-Store-Memcached distribution. |
Catalyst::Plugin::Session::Store::Memcached - Memcached storage backend for session data.
use Catalyst qw/ Session Session::Store::Memcached Session::State::Foo /;
MyApp->config(
'Plugin::Session' => {
memcached_new_args => {
# L<Cache::Memcached::Managed/new>
'data' => [ "10.0.0.15:11211", "10.0.0.15:11212" ],
},
memcached_item_args => {
# L<Cache::Memcached::Managed/set>, get, delete
# ...
},
},
);
# ... in an action:
$c->session->{foo} = 'bar'; # will be saved
Catalyst::Plugin::Session::Store::Memcached is a session storage plugin for
Catalyst that uses the Cache::Memcached::Managed module to connect to
memcached, a fast data caching server.
These are implementations of the required methods for a store. See Catalyst::Plugin::Session::Store.
Sets up the session cache file.
These parameters are placed in the hash under the Plugin::Session key in the
configuration hash.
If this key is a true value it will be used as the storage driver. It is assumed that it adheres to the same interface as Cache::Memcached::Managed.
This parameter is a hash reference which will be flattenned as the argument list to new in Cache::Memcached::Managed.
Some default values will be used:
The data server to use defaults to localhost:11211.
"catalyst_session"
Extra arguments to be passed into set, get, and delete. These are
discussed in Cache::Memcached::Managed.
Some default values will be used:
YourApp->VERSION
"YourApp"
This module is derived from Catalyst::Plugin::Session::FastMmap code, and has been heavily modified since.
Tomas Doran, (t0m) bobtfish@bobtfish.net - current maintainer.
Andrew Ford
Andy Grundman
Christian Hansen
Yuval Kogman, nothingmuch@woobling.org
Marcus Ramberg
Sebastian Riedel
head1 COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Plugin-Session-Store-Memcached documentation | Contained in the Catalyst-Plugin-Session-Store-Memcached distribution. |
package Catalyst::Plugin::Session::Store::Memcached; use strict; use warnings; use base qw/ Class::Accessor::Fast Class::Data::Inheritable Catalyst::Plugin::Session::Store /; use MRO::Compat; use Cache::Memcached::Managed; use Catalyst::Exception; our $VERSION = '0.04'; __PACKAGE__->mk_classdata($_) for qw/_session_memcached_storage _session_memcached_arg_fudge/;
sub get_session_data { my ( $c, $key ) = @_; $c->_session_memcached_storage->get( @{ $c->_session_memcached_arg_fudge }, id => $key, ); } sub store_session_data { my ( $c, $key, $data ) = @_; $c->_session_memcached_storage->set( @{ $c->_session_memcached_arg_fudge }, ( $key =~ /^(?:expires|session|flash)/ ? ( expiration => $c->session_expires ) : () ), id => $key, value => $data, ) or Catalyst::Exception->throw( "Couldn't save $key / $data in memcached storage"); } sub delete_session_data { my ( $c, $sid ) = @_; $c->_session_memcached_storage->delete( @{ $c->_session_memcached_arg_fudge }, id => $sid, ); } sub delete_expired_sessions { }
sub setup_session { my $c = shift; $c->maybe::next::method(@_); my $cfg = $c->_session_plugin_config; my $appname = "$c"; $c->_session_memcached_storage( my $storage = $cfg->{memcached_obj} || Cache::Memcached::Managed->new( data => "localhost:11211", namespace => "catalyst_session", %{ $cfg->{memcached_new_args} || {} }, ), ); $c->_session_memcached_arg_fudge( [ version => $appname->VERSION, key => $appname, %{ $cfg->{memcached_item_args} || {} }, ] ); }
1;