s/cleanup/remove/ in Store API
[catagits/Web-Session.git] / lib / Plack / Session / Store.pm
index e20c196..727ff42 100644 (file)
@@ -2,6 +2,9 @@ package Plack::Session::Store;
 use strict;
 use warnings;
 
+our $VERSION   = '0.03';
+our $AUTHORITY = 'cpan:STEVAN';
+
 use Plack::Util::Accessor qw[ _stash ];
 
 sub new {
@@ -11,30 +14,20 @@ sub new {
 }
 
 sub fetch {
-    my ($self, $session_id, $key) = @_;
-    $self->_stash->{ $session_id }->{ $key }
+    my ($self, $session_id) = @_;
+    $self->_stash->{ $session_id };
 }
 
 sub store {
-    my ($self, $session_id, $key, $data) = @_;
-    $self->_stash->{ $session_id }->{ $key } = $data;
+    my ($self, $session_id, $session) = @_;
+    $self->_stash->{ $session_id } = $session;
 }
 
-sub delete {
-    my ($self, $session_id, $key) = @_;
-    delete $self->_stash->{ $session_id }->{ $key };
-}
-
-sub cleanup {
+sub remove {
     my ($self, $session_id) = @_;
     delete $self->_stash->{ $session_id }
 }
 
-sub persist {
-    my ($self, $session_id, $response) = @_;
-    ()
-}
-
 1;
 
 __END__
@@ -45,31 +38,64 @@ __END__
 
 Plack::Session::Store - Basic in-memory session store
 
+=head1 SYNOPSIS
+
+  use Plack::Builder;
+  use Plack::Middleware::Session;
+  use Plack::Session::Store;
+
+  my $app = sub {
+      return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
+  };
+
+  builder {
+      enable 'Session'; # this is the defalt store
+      $app;
+  };
+
 =head1 DESCRIPTION
 
+This is a very basic in-memory session data store. It is volatile
+storage and not recommended for multiprocessing environments. However
+it is very useful for development and testing.
+
+This should be considered the store "base" class (although
+subclassing is not a requirement) and defines the spec for
+all B<Plack::Session::Store::*> modules. You will only
+need to override a couple methods if you do subclass. See
+the other B<Plack::Session::Store::*> for examples of this.
+
 =head1 METHODS
 
 =over 4
 
 =item B<new ( %params )>
 
+No parameters are expected to this constructor.
+
 =back
 
-=over 4
+=head2 Session Data Management
+
+These methods fetch data from the session storage. It's designed to
+store or delete multiple keys at a time.
 
-=item B<fetch ( $session_id, $key )>
+=over 4
 
-=item B<store ( $session_id, $key, $data )>
+=item B<fetch ( $session_id )>
 
-=item B<delete ( $session_id, $key )>
+=item B<store ( $session_id, $session )>
 
 =back
 
+=head2 Storage Management
+
 =over 4
 
-=item B<persist ( $session_id, $response )>
+=item B<remove ( $session_id )>
 
-=item B<cleanup ( $session_id )>
+This method is called by the L<Plack::Session> C<expire> method and
+is used to remove any session data.
 
 =back
 
@@ -85,7 +111,7 @@ Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2009 Infinity Interactive, Inc.
+Copyright 2009, 2010 Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>