Catalyst-Plugin-Session-Store-FastMmap-0.16/0000755000076500000240000000000011711732061017263 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/Changes0000644000076500000240000000345411711731167020572 0ustar t0mstaff0.16 24 Jan 2012 - Remove superfluous call to ->setup in test app 0.15 18 Jan 2012 - Moose-ified to fix https://rt.cpan.org/Ticket/Display.html?id=74132 (karpet) 0.14 18 Nov 2010 - Added "page_size" config option per RT #62335 (karpet) 0.13 18 Oct 2009 - Fixup copyright ino 0.12 16 Oct 2009 - Port to new session config key 0.11 16 June 2009 - Fixed warning during basic.t on Win32 - Added comment into doc about not being "thread-safe" 0.10 13 May 2009 - Change tests to be compatible with Catalyst 5.80004 - Re-add /session-file prefix to the test session directory which was present in 0.07. I can't see where this was removed, but the test looks more correct with it. RT#45724 0.09 04 May 2009 - remove Win32 hack since Cache::FastMmap 1.29 supports Win32. see https://rt.cpan.org/Ticket/Display.html?id=45642 0.08 01 May 2009 - Bump Cache::FastMmap requirement to 1.29 to fix RT#45210 0.07 30 Mar 2009 - Port from NEXT to MRO::Compat. 0.06 28 Jan 2009 - die when Cache::FastMmap::set() returns false value (RT #33667) - patch from ton.voon@altinity.com to pass unlink_on_exit option to Cache::FastMmap - correctly set storage path from config rather than default - karman - clean up temp files after tests 0.05 16 Jan 2008 - removed all Module::Build cruft - karman 0.04 - patch for Class::C3 compatability - karman 0.03 02 Jul 2007 - Add support for Win32 by using Cache::FastMmap::WithWin32 on MS platforms --Ash Berlin 0.02 01 Jan 2006 - Workaround Storable/Cache::FastMmap limitation with non reference data 0.01 14 Nov 2005 - Initial release. Catalyst-Plugin-Session-Store-FastMmap-0.16/lib/0000755000076500000240000000000011711732061020031 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/lib/Catalyst/0000755000076500000240000000000011711732061021615 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/lib/Catalyst/Plugin/0000755000076500000240000000000011711732061023053 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/lib/Catalyst/Plugin/Session/0000755000076500000240000000000011711732061024476 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/lib/Catalyst/Plugin/Session/Store/0000755000076500000240000000000011711732061025572 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/lib/Catalyst/Plugin/Session/Store/FastMmap.pm0000644000076500000240000001301711711732042027641 0ustar t0mstaffpackage Catalyst::Plugin::Session::Store::FastMmap; use strict; use Moose; use MRO::Compat; use namespace::clean -except => 'meta'; with 'Catalyst::ClassData'; with 'MooseX::Emulate::Class::Accessor::Fast'; extends 'Catalyst::Plugin::Session::Store'; use Cache::FastMmap; use Path::Class (); use File::Spec (); use Catalyst::Utils (); our $VERSION = '0.16'; __PACKAGE__->mk_classdata(qw/_session_fastmmap_storage/); =head1 NAME Catalyst::Plugin::Session::Store::FastMmap - FastMmap session storage backend. =head1 SYNOPSIS use Catalyst qw/Session Session::Store::FastMmap Session::State::Foo/; MyApp->config( 'Plugin::Session' => { expires => 3600, storage => '/tmp/session' }, ); # ... in an action: $c->session->{foo} = 'bar'; # will be saved =head1 DESCRIPTION C is a fast session storage plugin for Catalyst that uses an mmap'ed file to act as a shared memory interprocess cache. It is based on L. =head2 METHODS =over 4 =item get_session_data =item store_session_data =item delete_session_data =item delete_expired_sessions These are implementations of the required methods for a store. See L. =item get_and_set_session_data This is the optional method for atomic write semantics. See L. =cut sub get_session_data { my ( $c, $sid ) = @_; $c->_session_fastmmap_storage->get($sid); } sub store_session_data { my ( $c, $sid, $data ) = @_; $c->_session_fastmmap_storage->set( $sid, $data ) or Catalyst::Exception->throw("store_session: data too large"); } sub delete_session_data { my ( $c, $sid ) = @_; $c->_session_fastmmap_storage->remove($sid); } sub delete_expired_sessions { } # unsupported sub get_and_set_session_data { my ( $c, $sid, $sub ) = @_; $c->_session_fastmmap_storage->get_and_set( $sid, sub { my ( $key, $data ) = @_; my $new = $sub->( $key, $data ); return $new; }); } =item setup_session Sets up the session cache file. =cut sub setup_session { my $c = shift; $c->maybe::next::method(@_); my $tmpdir = Catalyst::Utils::class2tempdir($c) || Catalyst::Exception->throw("Can't determine tempdir for $c"); my $file = $c->_session_plugin_config->{storage} ||= File::Spec->catfile( # Cache::FastMmap doesn't like Path::Class objects $tmpdir, "session_data", ); my $dir = Path::Class::file($file)->parent; unless (-d $dir) { $dir->mkpath($c->debug); } if ($c->debug) { $c->log->debug("Session Store file: $file"); } my $cfg = $c->_session_plugin_config; $c->_session_fastmmap_storage( Cache::FastMmap->new( raw_values => 0, share_file => ($file . ''), # force serialize in case it is a Path::Class object ( map { $_ => $cfg->{$_} } grep { exists $cfg->{$_} } qw/init_file cache_size page_size unlink_on_exit/ ), ) ); } =back =head1 CAVEATS Very loaded sites with lots of data in the session hash may have old sessions expired prematurely, due to the LRU caching policy employed by L. To get around this you can increase the C parameter, or switch session storage backends. L defaults to around 5mb (89 * 64k). This is particularly inappropriate for use as a backend for e.g. L, for example. As L is not "thread-safe" (at least version 1.30 and before) therefore also this module does not work in multi-threaded environment. It is "fork-safe", however keep in mind that on Win32 the perl "fork" call is implemented as an emulation via threads - that is the reason why you cannot use this store for example when running you catalyst application on Win32 platform with L engine. =head1 CONFIGURATION These parameters are placed in the hash under the C key in the configuration hash. =over 4 =item storage Specifies the file to be used for the sharing of session data. The default value will use L to find the default tempdir, and use a file named C, where C is replaced with the appname. Note that the file will be created with mode 0640, which means that it will only be writeable by processes running with the same uid as the process that creates the file. If this may be a problem, for example if you may try to debug the program as one user and run it as another, specify a filename like C<< /tmp/session-$> >>, which includes the UID of the process in the filename. =item init_file =item cache_size =item unlink_on_exit See the L documentation for the meaning of these keys. If these keys are not present L's defaults will be used. =back =head1 SEE ALSO L, L, L. =head1 AUTHORS This module is derived from L code, and has been heavily modified since. Andrew Ford Andy Grundman Christian Hansen Yuval Kogman, Marcus Ramberg Sebastian Riedel Tomas Doran, (t0m) =head1 COPYRIGHT Copyright (c) 2005 - 2012 the Catalyst::Plugin::Session::Store::FastMmap L as listed above. =head1 LICENSE This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Catalyst-Plugin-Session-Store-FastMmap-0.16/Makefile.PL0000644000076500000240000000151411711731167021244 0ustar t0mstaffuse ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Catalyst::Plugin::Session::Store::FastMmap', 'VERSION_FROM' => 'lib/Catalyst/Plugin/Session/Store/FastMmap.pm', 'PREREQ_PM' => { 'Cache::FastMmap' => '1.29', 'Catalyst::Plugin::Session' => '0.27', 'File::Spec' => '0', 'File::Temp' => '0', 'Path::Class' => '0', 'MRO::Compat' => '0', 'Catalyst::Runtime' => '5.8', 'Catalyst::ClassData' => 0, 'MooseX::Emulate::Class::Accessor::Fast' => 0, }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; Catalyst-Plugin-Session-Store-FastMmap-0.16/MANIFEST0000644000076500000240000000047011711732061020415 0ustar t0mstaffChanges lib/Catalyst/Plugin/Session/Store/FastMmap.pm Makefile.PL MANIFEST This list of files META.yml README t/01use.t t/02pod.t t/03podcoverage.t t/basic.t t/lib/SessionStoreTest.pm t/lib/SessionStoreTest/Controller/Root.pm META.json Module JSON meta-data (added by MakeMaker) Catalyst-Plugin-Session-Store-FastMmap-0.16/META.json0000644000076500000240000000222311711732061020703 0ustar t0mstaff{ "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112621", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Catalyst-Plugin-Session-Store-FastMmap", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "Cache::FastMmap" : "1.29", "Catalyst::ClassData" : 0, "Catalyst::Plugin::Session" : "0.27", "Catalyst::Runtime" : "5.8", "File::Spec" : 0, "File::Temp" : 0, "MRO::Compat" : 0, "MooseX::Emulate::Class::Accessor::Fast" : 0, "Path::Class" : 0 } } }, "release_status" : "stable", "version" : "0.16" } Catalyst-Plugin-Session-Store-FastMmap-0.16/META.yml0000644000076500000240000000123511711732061020535 0ustar t0mstaff--- abstract: unknown author: - unknown build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.59, CPAN::Meta::Converter version 2.112621' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Catalyst-Plugin-Session-Store-FastMmap no_index: directory: - t - inc requires: Cache::FastMmap: 1.29 Catalyst::ClassData: 0 Catalyst::Plugin::Session: 0.27 Catalyst::Runtime: 5.8 File::Spec: 0 File::Temp: 0 MRO::Compat: 0 MooseX::Emulate::Class::Accessor::Fast: 0 Path::Class: 0 version: 0.16 Catalyst-Plugin-Session-Store-FastMmap-0.16/README0000644000076500000240000000557011265132463020156 0ustar t0mstaffNAME Catalyst::Plugin::Session::Store::FastMmap - FastMmap session storage backend. SYNOPSIS use Catalyst qw/Session Session::Store::FastMmap Session::State::Foo/; MyApp->config->{session} = { expires => 3600, storage => '/tmp/session' }; # ... in an action: $c->session->{foo} = 'bar'; # will be saved DESCRIPTION "Catalyst::Plugin::Session::Store::FastMmap" is a fast session storage plugin for Catalyst that uses an mmap'ed file to act as a shared memory interprocess cache. It is based on Cache::FastMmap. METHODS get_session_data store_session_data delete_session_data delete_expired_sessions These are implementations of the required methods for a store. See Catalyst::Plugin::Session::Store. get_and_set_session_data This is the optional method for atomic write semantics. See Catalyst::Plugin::Session::AtomicWrite. setup_session Sets up the session cache file. CAVEATS Very loaded sites with lots of data in the session hash may have old sessions expired prematurely, due to the LRU caching policy employed by Cache::FastMmap. To get around this you can increase the "cache_size" parameter, or switch session storage backends. This is particularly inappropriate for use as a backend for e.g. Catalyst::Plugin::Session::PerUser, for example. Cache::FastMmap defaults to around 5mb (89 * 64k). CONFIGURATION These parameters are placed in the hash under the "session" key in the configuration hash. storage Specifies the file to be used for the sharing of session data. The default value will use File::Spec to find the default tempdir, and use a file named "MyApp_session_data", where "MyApp" is replaced with the appname. Note that the file will be created with mode 0640, which means that it will only be writeable by processes running with the same uid as the process that creates the file. If this may be a problem, for example if you may try to debug the program as one user and run it as another, specify a filename like "/tmp/session-$>", which includes the UID of the process in the filename. init_file cache_size See the Cache::FastMmap documentation for the meaning of these keys. If these keys are not present Cache::FastMmap's defaults will be used. SEE ALSO Catalyst, Catalyst::Plugin::Session, Cache::FastMmap. AUTHORS This module is derived from Catalyst::Plugin::Session::FastMmap code, and has been heavily modified since. Andrew Ford Andy Grundman Christian Hansen Yuval Kogman, "nothingmuch@woobling.org" Marcus Ramberg Sebastian Riedel COPYRIGHT This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Catalyst-Plugin-Session-Store-FastMmap-0.16/t/0000755000076500000240000000000011711732061017526 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/t/01use.t0000644000076500000240000000034111265132463020652 0ustar t0mstaffuse strict; use Test::More tests => 1; BEGIN { use_ok('Catalyst::Plugin::Session::Store::FastMmap') } diag("testing Catalyst::Plugin::Session::Store::FastMmap version $Catalyst::Plugin::Session::Store::FastMmap::VERSION"); Catalyst-Plugin-Session-Store-FastMmap-0.16/t/02pod.t0000644000076500000240000000027611265132463020650 0ustar t0mstaffuse Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Catalyst-Plugin-Session-Store-FastMmap-0.16/t/03podcoverage.t0000644000076500000240000000032511265132463022360 0ustar t0mstaffuse Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok(); Catalyst-Plugin-Session-Store-FastMmap-0.16/t/basic.t0000644000076500000240000000033011265132463020774 0ustar t0mstaffuse strict; use warnings; use FindBin qw/$Bin/; use lib "$Bin/lib"; use Catalyst::Test "SessionStoreTest"; use Test::More; my $x = get("/store_scalar"); is(get('/get_scalar'), 456, 'Can store scalar value okay'); Catalyst-Plugin-Session-Store-FastMmap-0.16/t/lib/0000755000076500000240000000000011711732061020274 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/t/lib/SessionStoreTest/0000755000076500000240000000000011711732061023574 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/t/lib/SessionStoreTest/Controller/0000755000076500000240000000000011711732061025717 5ustar t0mstaffCatalyst-Plugin-Session-Store-FastMmap-0.16/t/lib/SessionStoreTest/Controller/Root.pm0000644000076500000240000000052311711731167027206 0ustar t0mstaff#!/usr/bin/perl package SessionStoreTest::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; 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'} ); } 1; Catalyst-Plugin-Session-Store-FastMmap-0.16/t/lib/SessionStoreTest.pm0000644000076500000240000000103011711731167024132 0ustar t0mstaff#!/usr/bin/perl use strict; use warnings; use File::Temp; use File::Spec; use Catalyst::Plugin::Session::Test::Store ( backend => "FastMmap", config => { storage => scalar( File::Temp::tmpnam() ) }, # we do not care in this package about deleting temporary file as it is # removed automatically by Cache::FastMmap extra_tests => 1 ); { package SessionStoreTest; use Catalyst; # we don't call ->setup because C::P::Session::Test::Store above # calls it for us. -- apeiron, 2012-01-25 } 1;