[Catalyst-commits] r6489 - in
trunk/Catalyst-Plugin-Session-Store-FastMmap: .
lib/Catalyst/Plugin/Session/Store t
ash at dev.catalyst.perl.org
ash at dev.catalyst.perl.org
Sun Jul 1 22:22:16 GMT 2007
Author: ash
Date: 2007-07-01 22:22:16 +0100 (Sun, 01 Jul 2007)
New Revision: 6489
Modified:
trunk/Catalyst-Plugin-Session-Store-FastMmap/Build.PL
trunk/Catalyst-Plugin-Session-Store-FastMmap/lib/Catalyst/Plugin/Session/Store/FastMmap.pm
trunk/Catalyst-Plugin-Session-Store-FastMmap/t/basic.t
Log:
Use Cache::FastMmap::WithWin32 on windows, and remove ref hacks since Cache::FastMmap handles this now
Modified: trunk/Catalyst-Plugin-Session-Store-FastMmap/Build.PL
===================================================================
--- trunk/Catalyst-Plugin-Session-Store-FastMmap/Build.PL 2007-07-01 04:51:03 UTC (rev 6488)
+++ trunk/Catalyst-Plugin-Session-Store-FastMmap/Build.PL 2007-07-01 21:22:16 UTC (rev 6489)
@@ -7,7 +7,10 @@
module_name => 'Catalyst::Plugin::Session::Store::FastMmap',
requires => {
'Catalyst::Plugin::Session' => '0.01',
- 'Cache::FastMmap' => 0,
+ ($^O eq 'MSWin32'
+ ? 'Cache::FastMmap::WithWin32'
+ : 'Cache::FastMmap'
+ ) => 1.13,
'File::Temp' => 0,
'File::Spec' => 0,
'Path::Class' => 0,
Modified: trunk/Catalyst-Plugin-Session-Store-FastMmap/lib/Catalyst/Plugin/Session/Store/FastMmap.pm
===================================================================
--- trunk/Catalyst-Plugin-Session-Store-FastMmap/lib/Catalyst/Plugin/Session/Store/FastMmap.pm 2007-07-01 04:51:03 UTC (rev 6488)
+++ trunk/Catalyst-Plugin-Session-Store-FastMmap/lib/Catalyst/Plugin/Session/Store/FastMmap.pm 2007-07-01 21:22:16 UTC (rev 6489)
@@ -1,10 +1,17 @@
package Catalyst::Plugin::Session::Store::FastMmap;
use strict;
-use base
- qw/Class::Data::Inheritable Class::Accessor::Fast Catalyst::Plugin::Session::Store/;
+use base qw/
+ Class::Data::Inheritable
+ Class::Accessor::Fast
+ Catalyst::Plugin::Session::Store/;
+
use NEXT;
-use Cache::FastMmap;
+
+BEGIN {
+ require Cache::FastMmap if $^O ne 'MSWin32';
+ require Cache::FastMmap::WithWin32 if $^O eq 'MSWin32';
+}
use Path::Class ();
use File::Spec ();
use Catalyst::Utils ();
@@ -57,19 +64,14 @@
=cut
-# The reference business is because Cache::FastMmap delegates to Storable with
-# no intervention, meaning that non reference data cannot be stored.
-# see L<https://rt.cpan.org/NoAuth/Bug.html?id=16762>
-# FIXME remember to remove this hack when the new version of Cache::FastMmap is
-# out, and to rely on it
sub get_session_data {
my ( $c, $sid ) = @_;
- ${ $c->_session_fastmmap_storage->get($sid) || return };
+ $c->_session_fastmmap_storage->get($sid);
}
sub store_session_data {
my ( $c, $sid, $data ) = @_;
- $c->_session_fastmmap_storage->set( $sid, \$data );
+ $c->_session_fastmmap_storage->set( $sid, $data );
}
sub delete_session_data {
@@ -83,8 +85,8 @@
my ( $c, $sid, $sub ) = @_;
$c->_session_fastmmap_storage->get_and_set( $sid, sub {
my ( $key, $data ) = @_;
- my $new = $sub->( $key, $$data ); # YUCK about the $$data - see above FIXME
- return \$new;
+ my $new = $sub->( $key, $data );
+ return $new;
});
}
@@ -114,6 +116,7 @@
$c->_session_fastmmap_storage(
Cache::FastMmap->new(
+ raw_values => 0,
share_file => $cfg->{storage},
(
map { $_ => $cfg->{$_} }
Modified: trunk/Catalyst-Plugin-Session-Store-FastMmap/t/basic.t
===================================================================
--- trunk/Catalyst-Plugin-Session-Store-FastMmap/t/basic.t 2007-07-01 04:51:03 UTC (rev 6488)
+++ trunk/Catalyst-Plugin-Session-Store-FastMmap/t/basic.t 2007-07-01 21:22:16 UTC (rev 6489)
@@ -12,5 +12,32 @@
storage => ( my $tmp = File::Temp->new( UNLINK => 1 ) )
->filename, # $tmp: positive refcount
},
+ extra_tests => 1
);
+{
+ package SessionStoreTest;
+
+ sub store_scalar : Global {
+ my ($self, $c) = @_;
+
+ $c->res->body($c->session->{'scalar'} = 456);
+ }
+
+ sub get_scalar : Global {
+ my ($self, $c) = @_;
+
+ $c->res->body($c->session->{'scalar'});
+ }
+
+ __PACKAGE__->setup_actions;
+
+}
+
+{
+ use Catalyst::Test "SessionStoreTest";
+ use Test::More;
+
+ get("/store_scalar");
+ is(get('/get_scalar'), 456, 'Can store scalar value okay');
+}
More information about the Catalyst-commits
mailing list