docs, docs and more docs
[catagits/Web-Session.git] / lib / Plack / Session / Store.pm
CommitLineData
06190e8b 1package Plack::Session::Store;
2use strict;
3use warnings;
4
5use Plack::Util::Accessor qw[ _stash ];
6
ac4892f4 7sub new {
8 my ($class, %params) = @_;
9 $params{'_stash'} ||= +{};
10 bless { %params } => $class;
11}
06190e8b 12
13sub fetch {
14 my ($self, $session_id, $key) = @_;
15 $self->_stash->{ $session_id }->{ $key }
16}
17
18sub store {
19 my ($self, $session_id, $key, $data) = @_;
20 $self->_stash->{ $session_id }->{ $key } = $data;
21}
22
23sub delete {
24 my ($self, $session_id, $key) = @_;
25 delete $self->_stash->{ $session_id }->{ $key };
26}
27
06190e8b 28sub cleanup {
29 my ($self, $session_id) = @_;
30 delete $self->_stash->{ $session_id }
31}
32
ac4892f4 33sub persist {
34 my ($self, $session_id, $response) = @_;
35 ()
36}
37
381;
39
40__END__
41
42=pod
43
44=head1 NAME
45
46Plack::Session::Store - Basic in-memory session store
47
48=head1 DESCRIPTION
49
50=head1 METHODS
51
52=over 4
53
54=item B<new ( %params )>
55
56=back
57
43f34c01 58=head2 Session Data Management
59
ac4892f4 60=over 4
61
62=item B<fetch ( $session_id, $key )>
63
64=item B<store ( $session_id, $key, $data )>
65
66=item B<delete ( $session_id, $key )>
67
68=back
69
43f34c01 70=head2 Storage Management
71
ac4892f4 72=over 4
73
74=item B<persist ( $session_id, $response )>
75
43f34c01 76This method will perform any data persistence nessecary to maintain
77data across requests. This method is called by the L<Plack::Session>
78C<finalize> method. The C<$response> is expected to be a L<Plack::Response>
79instance or an object with an equivalent interface.
80
ac4892f4 81=item B<cleanup ( $session_id )>
82
43f34c01 83This method is called by the L<Plack::Session> C<expire> method and
84is used to remove any session data.
85
ac4892f4 86=back
87
88=head1 BUGS
89
90All complex software has bugs lurking in it, and this module is no
91exception. If you find a bug please either email me, or add the bug
92to cpan-RT.
93
94=head1 AUTHOR
95
96Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
97
98=head1 COPYRIGHT AND LICENSE
99
100Copyright 2009 Infinity Interactive, Inc.
101
102L<http://www.iinteractive.com>
103
104This library is free software; you can redistribute it and/or modify
105it under the same terms as Perl itself.
106
107=cut
108