Apache-Session-Memcached-0.03/0040755000175000001440000000000010123516006014736 5ustar bepiusersApache-Session-Memcached-0.03/t/0040755000175000001440000000000010123516006015201 5ustar bepiusersApache-Session-Memcached-0.03/t/01cache.t0100644000175000001440000000103410123337527016576 0ustar bepiusersuse strict; use Test; use Apache::Session::Memcached; BEGIN { plan tests => 4 } require 't/testlib.pl'; my %config = read_config('t/CONFIG','Generate Serialize Servers'); ok(1); my $session; tie %{$session}, 'Apache::Session::Memcached', undef, { Servers => $config{Servers}, }; my $sid = $session->{_session_id}; ok( $session->{foo} = 'bar' ); untie %{$session}; tie %{$session}, 'Apache::Session::Memcached', $sid, { Servers => [ split(/\s+/,$config{Servers}) ], }; ok($session->{foo},'bar'); tied(%{$session})->delete; ok(1); Apache-Session-Memcached-0.03/t/CONFIG0100644000175000001440000000045210122661425016074 0ustar bepiusers# this file contains testing parameters for Apache::Session::Memcached # Note: params have to be all on one line # Session ID generation scheme Generate = MD5 # Serialization scheme Serialize = Storable # memcached servers. It must be on the form: IP:port IP:port ... Servers = 127.0.0.1:20000 Apache-Session-Memcached-0.03/t/02flex.t0100644000175000001440000000134610123337474016501 0ustar bepiusersuse strict; use Test; use Apache::Session::Flex; BEGIN { plan tests => 4 } require 't/testlib.pl'; my %config = read_config('t/CONFIG','Generate Serialize Servers'); ok(1); my $session; tie %{$session}, 'Apache::Session::Flex', undef, { Store => 'Memcached', Lock => 'Null', Generate => $config{Generate}, Serialize => $config{Serialize}, Servers => $config{Servers}, }; my $sid = $session->{_session_id}; ok( $session->{foo} = 'bar' ); untie %{$session}; tie %{$session}, 'Apache::Session::Flex', $sid, { Store => 'Memcached', Lock => 'Null', Generate => $config{Generate}, Serialize => $config{Serialize}, Servers => $config{Servers}, }; ok($session->{foo},'bar'); tied(%{$session})->delete; ok(1); Apache-Session-Memcached-0.03/t/testlib.pl0100644000175000001440000000061410122334551017204 0ustar bepiuserssub read_config { my ($filename,$directives) = @_; open(CFG, "$filename") || die "Can't open $filename: $!"; local $/; my $config_line = ; my %config; foreach ( split(/\s+/,$directives) ) { $config{$_} = get_config($config_line,$_); } return %config; } sub get_config { my ($config, $param) = @_; if ($config =~ /^$param\s*?=\s*(.*?)$/m) { return $1; } return ''; } 1; Apache-Session-Memcached-0.03/t/00base.t0100644000175000001440000000021010122323364016430 0ustar bepiusersBEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Apache::Session::Memcached; $loaded = 1; print "ok 1\n"; Apache-Session-Memcached-0.03/lib/0040755000175000001440000000000010123516006015504 5ustar bepiusersApache-Session-Memcached-0.03/lib/Apache/0040755000175000001440000000000010123516006016665 5ustar bepiusersApache-Session-Memcached-0.03/lib/Apache/Session/0040755000175000001440000000000010123516006020310 5ustar bepiusersApache-Session-Memcached-0.03/lib/Apache/Session/Store/0040755000175000001440000000000010123516006021404 5ustar bepiusersApache-Session-Memcached-0.03/lib/Apache/Session/Store/Memcached.pm0100644000175000001440000000653410123514023023612 0ustar bepiuserspackage Apache::Session::Store::Memcached; use Cache::Memcached; use strict; use vars qw($VERSION); $VERSION = '0.03'; sub new { my($class,$session) = @_; my $self; my %opts = ( servers => ( ref $session->{args}->{Servers} eq 'ARRAY' ) ? $session->{args}->{Servers} : [ split(/\s+/,$session->{args}->{Servers}) ], no_rehash => $session->{args}->{NoRehash}, readonly => $session->{args}->{ReadOnly}, debug => $session->{args}->{Debug}, compress_threshold => $session->{args}->{CompressThreshold} || 10_000, ); #use Data::Dumper; #print STDERR Dumper $session->{args}; my $memd = new Cache::Memcached \%opts; $self->{cache} = $memd; bless $self,$class; } sub insert { my($self,$session) = @_; if ( $self->{cache}->get($session->{data}->{_session_id}) ) { die "Object already exists in the data store."; } $self->{cache}->set($session->{data}->{_session_id},$session->{serialized}); } sub update { my($self,$session) = @_; $self->{cache}->replace($session->{data}->{_session_id},$session->{serialized}); } sub materialize { my($self, $session) = @_; $session->{serialized} = $self->{cache}->get($session->{data}->{_session_id}) or die 'Object does not exist in data store.'; } sub remove { my($self, $session) = @_; $self->{cache}->delete($session->{data}->{_session_id}); } 1; __END__ =head1 NAME Apache::Session::Store::Memcached - Stores persistent data using memcached (memory cache daemon) for Apache::Session storage =head1 SYNOPSIS tie %session, 'Apache::Session::Memcached', $sid, { Servers => '10.0.0.1:20000 10.0.0.2:20000', NoRehash => 1, Readonly => 0, Debug => 1, CompressThreshold => 10_000 }; # use with another locking/generation/serializaion scheme use Apache::Session::Flex; tie %session, 'Apache::Session::Flex', $id, { Store => 'Memcached', Lock => 'Null', Generate => 'MD5', Serialize => 'Storable', Servers => '10.0.0.1:20000 10.0.0.2:20000', }; =head1 DESCRIPTION Apache::Session::Store::Memcached implements the storage interface for Apache::Session using Cache::Memcached frontend to memcached. =head1 CONFIGURATIONS This module wants to know standard options for Cache::Memcached. You can specify these options as Apache::Session's tie options like this: tie %session, 'Apache::Session::Memcached', $sid, { Servers => '10.0.0.1:20000 10.0.0.2:20000', Debug => 1 }; Note that spelling of options are slightly different from those for Cache::Memcached. 'Servers', 'NoRehash', 'Readonly', 'Debug' and 'CompressThreshold' are the corrispondant to 'servers', 'no_rehash', 'readonly', 'debug' and 'compress_threshold' Cache::Memcached parameters. In addition 'Server' can be either a scalar of the form 'IP:port IP:port ...', either an arrayref of hosts (as required by Cache::Memcached). See L for details. =head1 SEE ALSO L, L, L, L. =head1 AUTHOR Enrico Sorcinelli Eenrico at sorcinelliE =head1 COPYRIGHT AND LICENSE Copyright (C) 2004 by Enrico Sorcinelli This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Memcached-0.03/lib/Apache/Session/Memcached.pm0100644000175000001440000000474210123514012022513 0ustar bepiuserspackage Apache::Session::Memcached; use strict; use vars qw($VERSION); $VERSION = '0.03'; use base qw(Apache::Session); use Apache::Session::Generate::MD5; use Apache::Session::Lock::Null; use Apache::Session::Serialize::Storable; use Apache::Session::Store::Memcached; sub populate { my $self = shift; $self->{object_store} = Apache::Session::Store::Memcached->new($self); $self->{lock_manager} = Apache::Session::Lock::Null->new($self); $self->{generate} = \&Apache::Session::Generate::MD5::generate; $self->{validate} = \&Apache::Session::Generate::MD5::validate; $self->{serialize} = \&Apache::Session::Serialize::Storable::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Storable::unserialize; return $self; } 1; __END__ =head1 NAME Apache::Session::Memcached - Stores persistent data using memcached (memory cache daemon) for Apache::Session storage =head1 SYNOPSIS use Apache::Session::Memcached; tie %session, 'Apache::Session::Memcached', $sid, { Servers => '10.0.0.1:20000 10.0.0.2:20000', NoRehash => 1, Readonly => 0, Debug => 1, CompressThreshold => 10_000 }; =head1 DESCRIPTION Apache::Session::Memcached is a bridge between Apache::Session and memcached, a distributed memory cache daemon. More informations about memcached are available at L. This module provides a way to use Cache::Memcached (memcached Perl API) as Apache::Session storage implementation. =head1 INSTALLATION In order to install and use this package you will need Perl version 5.005 or better. Prerequisites: =over 4 =item * Apache::Session >= 1.54 =item * Cache::Memcached >= 1.14 =back Installation as usual: %> perl Makefile.PL %> make %> make test %> make install Note: for live tests, you must run at least a memcached daemon and you could need to edit t/CONFIG file, in order to set correct parameters used for testing. =head1 SEE ALSO L, L, L, L, L. =head1 AUTHOR Enrico Sorcinelli Eenrico at sorcinelliE =head1 COPYRIGHT AND LICENSE Copyright (C) 2004 by Enrico Sorcinelli This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Memcached-0.03/MANIFEST0100644000175000001440000000036110122335314016064 0ustar bepiusersChanges Makefile.PL MANIFEST README lib/Apache/Session/Memcached.pm lib/Apache/Session/Store/Memcached.pm t/00base.t t/01cache.t t/02flex.t t/CONFIG t/testlib.pl META.yml Module meta-data (added by MakeMaker) Apache-Session-Memcached-0.03/Changes0100644000175000001440000000113310123515652016232 0ustar bepiusersRevision history for Perl extension Apache::Session::Memcached. Legenda: + = new feature, ! = updated feature/bug fix, - = removed feature 0.03 Mon Sep 20 13:00:00 2004 ! Fixed 'remove' session method with 'delete' Cache::Memcached call + Added delete calls in tests 0.02 Fri Sep 17 08:00:00 2004 + First CPAN public release + Added tests and improved docs 0.01 Mon Sep 13 16:37:12 2004 + original version; created by h2xs 1.23 with options -X -A -n Apache::Session::Memcached + Posted the RFC (and an alpha release) to comp.lang.perl.modules and module-authors@perl.org mailing list Apache-Session-Memcached-0.03/README0100644000175000001440000000215210123515642015620 0ustar bepiusersApache-Session-Memcached version 0.03 ===================================== Apache::Session::Memcached stores persistent data using memcached (memory cache daemon) for Apache::Session storage See: perldoc Apache::Session::Memcached perldoc Apache::Session::Memcached::Store for module documentation and use CHANGES FROM PREVIOUS VERSION ! Fixed 'remove' session method with 'delete' Cache::Memcached call + Added delete calls in tests See 'Changes' file in this distribution for complete history revision INSTALLATION To install this module type the following: %> perl Makefile.PL %> make %> make test %> make install Note: for live tests, you must run at least a memcached daemon and you could need to edit t/CONFIG file, in order to set correct parameters used for testing. DEPENDENCIES This module requires these other modules and libraries: - Apache::Session >= 1.54 - Cache::Memcached >= 1.14 COPYRIGHT AND LICENCE Copyright (C) 2001-2004 Enrico Sorcinelli. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Apache-Session-Memcached-0.03/META.yml0100644000175000001440000000063410123516006016207 0ustar bepiusers# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Apache-Session-Memcached version: 0.03 version_from: lib/Apache/Session/Memcached.pm installdirs: site requires: Apache::Session: 1.54 Cache::Memcached: 1.14 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Apache-Session-Memcached-0.03/Makefile.PL0100644000175000001440000000116110122335354016710 0ustar bepiusersuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Apache::Session::Memcached', VERSION_FROM => 'lib/Apache/Session/Memcached.pm', # finds $VERSION PREREQ_PM => { 'Cache::Memcached' => 1.14, 'Apache::Session' => 1.54, }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Apache/Session/Memcached.pm', # retrieve abstract from module AUTHOR => 'Enrico Sorcinelli ') : ()), );