e20c196573576178b1b8ab2af609f5d55cf8ef7c
[catagits/Web-Session.git] / lib / Plack / Session / Store.pm
1 package Plack::Session::Store;
2 use strict;
3 use warnings;
4
5 use Plack::Util::Accessor qw[ _stash ];
6
7 sub new {
8     my ($class, %params) = @_;
9     $params{'_stash'} ||= +{};
10     bless { %params } => $class;
11 }
12
13 sub fetch {
14     my ($self, $session_id, $key) = @_;
15     $self->_stash->{ $session_id }->{ $key }
16 }
17
18 sub store {
19     my ($self, $session_id, $key, $data) = @_;
20     $self->_stash->{ $session_id }->{ $key } = $data;
21 }
22
23 sub delete {
24     my ($self, $session_id, $key) = @_;
25     delete $self->_stash->{ $session_id }->{ $key };
26 }
27
28 sub cleanup {
29     my ($self, $session_id) = @_;
30     delete $self->_stash->{ $session_id }
31 }
32
33 sub persist {
34     my ($self, $session_id, $response) = @_;
35     ()
36 }
37
38 1;
39
40 __END__
41
42 =pod
43
44 =head1 NAME
45
46 Plack::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
58 =over 4
59
60 =item B<fetch ( $session_id, $key )>
61
62 =item B<store ( $session_id, $key, $data )>
63
64 =item B<delete ( $session_id, $key )>
65
66 =back
67
68 =over 4
69
70 =item B<persist ( $session_id, $response )>
71
72 =item B<cleanup ( $session_id )>
73
74 =back
75
76 =head1 BUGS
77
78 All complex software has bugs lurking in it, and this module is no
79 exception. If you find a bug please either email me, or add the bug
80 to cpan-RT.
81
82 =head1 AUTHOR
83
84 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
85
86 =head1 COPYRIGHT AND LICENSE
87
88 Copyright 2009 Infinity Interactive, Inc.
89
90 L<http://www.iinteractive.com>
91
92 This library is free software; you can redistribute it and/or modify
93 it under the same terms as Perl itself.
94
95 =cut
96