1 package Plack::Session::Store;
5 use Plack::Util::Accessor qw[ _stash ];
8 my ($class, %params) = @_;
9 $params{'_stash'} ||= +{};
10 bless { %params } => $class;
14 my ($self, $session_id, $key) = @_;
15 $self->_stash->{ $session_id }->{ $key }
19 my ($self, $session_id, $key, $data) = @_;
20 $self->_stash->{ $session_id }->{ $key } = $data;
24 my ($self, $session_id, $key) = @_;
25 delete $self->_stash->{ $session_id }->{ $key };
29 my ($self, $session_id) = @_;
30 delete $self->_stash->{ $session_id }
34 my ($self, $session_id, $response) = @_;
46 Plack::Session::Store - Basic in-memory session store
51 use Plack::Middleware::Session;
52 use Plack::Session::Store;
55 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
59 enable 'Session'; # this is the defalt store
65 This is a very basic in-memory session data store. It is volatile
66 storage and not recommended for multiprocessing environments. However
67 it is very useful for development and testing.
69 This should be considered the store "base" class (although
70 subclassing is not a requirement) and defines the spec for
71 all B<Plack::Session::Store::*> modules. You will only
72 need to override a couple methods if you do subclass. See
73 the other B<Plack::Session::Store::*> for examples of this.
79 =item B<new ( %params )>
81 No parameters are expected to this constructor.
85 =head2 Session Data Management
87 These methods fetch data from the session storage. It can only fetch,
88 store or delete a single key at a time.
92 =item B<fetch ( $session_id, $key )>
94 =item B<store ( $session_id, $key, $data )>
96 =item B<delete ( $session_id, $key )>
100 =head2 Storage Management
104 =item B<persist ( $session_id, $response )>
106 This method will perform any data persistence nessecary to maintain
107 data across requests. This method is called by the L<Plack::Session>
108 C<finalize> method. The C<$response> is expected to be a L<Plack::Response>
109 instance or an object with an equivalent interface.
111 =item B<cleanup ( $session_id )>
113 This method is called by the L<Plack::Session> C<expire> method and
114 is used to remove any session data.
120 All complex software has bugs lurking in it, and this module is no
121 exception. If you find a bug please either email me, or add the bug
126 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
128 =head1 COPYRIGHT AND LICENSE
130 Copyright 2009 Infinity Interactive, Inc.
132 L<http://www.iinteractive.com>
134 This library is free software; you can redistribute it and/or modify
135 it under the same terms as Perl itself.