Checking in changes prior to tagging of version 0.10. Changelog diff is:
[catagits/Web-Session.git] / lib / Plack / Session / Store / Cache.pm
index 399c608..b504050 100644 (file)
@@ -2,7 +2,10 @@ package Plack::Session::Store::Cache;
 use strict;
 use warnings;
 
-use Scalar::Util qw/blessed/;
+our $VERSION   = '0.10';
+our $AUTHORITY = 'cpan:STEVAN';
+
+use Scalar::Util qw[ blessed ];
 
 use parent 'Plack::Session::Store';
 
@@ -21,34 +24,16 @@ sub new {
 }
 
 sub fetch {
-    my ($self, $session_id, $key) = @_;
-    my $cache = $self->cache->get($session_id);
-    return unless $cache;
-    return $cache->{ $key };
+    my ($self, $session_id ) = @_;
+    $self->cache->get($session_id);
 }
 
 sub store {
-    my ($self, $session_id, $key, $data) = @_;
-    my $cache = $self->cache->get($session_id);
-    if ( !$cache ) {
-        $cache = {$key => $data};
-    }
-    else {
-        $cache->{$key} = $data;
-    }
-    $self->cache->set($session_id => $cache);
+    my ($self, $session_id, $session) = @_;
+    $self->cache->set($session_id => $session);
 }
 
-sub delete {
-    my ($self, $session_id, $key) = @_;
-    my $cache = $self->cache->get($session_id);
-    return unless exists $cache->{$key};
-
-    delete $cache->{ $key };
-    $self->cache->set($session_id => $cache);
-}
-
-sub cleanup {
+sub remove {
     my ($self, $session_id) = @_;
     $self->cache->remove($session_id);
 }
@@ -83,9 +68,9 @@ Plack::Session::Store::Cache - Cache session store
 
 =head1 DESCRIPTION
 
-This will persist session data using the L<Cache> module. This
-offers a lot of flexibility due to the many excellent L<CHI>
-drivers available.
+This will persist session data using any module which implements the
+L<Cache> interface. This offers a lot of flexibility due to the many
+excellent L<Cache>, L<Cache::Cache> and L<CHI> drivers available.
 
 This is a subclass of L<Plack::Session::Store> and implements
 it's full interface.
@@ -96,12 +81,14 @@ it's full interface.
 
 =item B<new ( %params )>
 
-The constructor expects an the I<cache> param to be an
-instance have get, set, and remove method, it will throw an exception
-if that is not the case.
+The constructor expects the I<cache> param to be an object instance
+which has the I<get>, I<set>, and I<remove> methods, it will throw an
+exception if that is not the case.
 
 =item B<cache>
 
+A simple accessor for the cache handle.
+
 =back
 
 =head1 BUGS