Apache2-WebApp-Plugin-Session-Memcached

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

abstract: Store persistent data using memcached (memory cache daemon)
version: 0.13
author:
  - Marc S. Brooks <mbrooks@cpan.org>
license: perl
distribution_type: module
requires:
  Apache::Session::Memcached: 0.03
  Apache::Session::Store::Memcached: 0.03
  Apache2::WebApp: 0.39
  Apache2::WebApp::Plugin::Cookie: 0.10
  Apache2::WebApp::Plugin::Session: 0.16
  Params::Validate: 0
build_requires:
  Apache::Test: 0
resources:
  license: http://dev.perl.org/licenses/
meta-spec:
  version: 1.4
  url: http://module-build.sourceforge.net/META-spec-v1.4.html

Makefile.PL  view on Meta::CPAN


WriteMakefile(
    NAME         => 'Apache2::WebApp::Plugin::Session::Memcached',
    VERSION_FROM => 'lib/Apache2/WebApp/Plugin/Session/Memcached.pm', # finds \$VERSION
    AUTHOR       => 'Marc S. Brooks (mbrooks@cpan.org)',
    PREREQ_PM => {
        'Apache::Test'                       => 0,
        'Apache::Session::Memcached'         => 0.03,
        'Apache::Session::Store::Memcached'  => 0.03,
        'Apache2::WebApp'                    => 0.39,
        'Apache2::WebApp::Plugin::Cookie'    => 0.10,
        'Apache2::WebApp::Plugin::Session'   => 0.16,
        'Params::Validate'                   => 0,
    },
    clean => {
        FILES => "@{ clean_files() }",
    }
);

sub clean_files {
    return [@scripts];

README  view on Meta::CPAN

    maintaining a stateful session using web browser cookies.

    <http://www.danga.com/memcached>

PREREQUISITES
    This package is part of a larger distribution and was NOT intended to be
    used directly. In order for this plugin to work properly, the following
    packages must be installed:

      Apache2::WebApp
      Apache2::WebApp::Plugin::Cookie
      Apache2::WebApp::Plugin::Session
      Apache::Session::Memcached
      Apache::Session::Store::Memcached
      Params::Validate

INSTALLATION
    From source:

      $ tar xfz Apache2-WebApp-Plugin-Session-Memcached-0.X.X.tar.gz
      $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib

README  view on Meta::CPAN


      [memcached]
      servers   = 127.0.0.1:11211, 10.0.0.10:11212, /var/sock/memcached
      threshold = 10_000

OBJECT METHODS
    Please refer to Apache2::WebApp::Plugin::Session for method info.

SEE ALSO
    Apache2::WebApp, Apache2::WebApp::Plugin,
    Apache2::WebApp::Plugin::Cookie, Apache2::WebApp::Plugin::Memcached,
    Apache2::WebApp::Plugin::Session, Apache::Session,
    Apache::Session::Memcached

AUTHOR
    Marc S. Brooks, <mbrooks@cpan.org> - <http://mbrooks.info>

COPYRIGHT
    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    }

    foreach my $key (keys %$data_ref) {
        $session{$key} = $data_ref->{$key};     # merge hash key/values
    }

    my $id = $session{_session_id};

    untie %session;

    $c->plugin('Cookie')->set($c, {
        name    => $name,
        value   => $id,
        expires => $c->config->{session_expires} || '24h',
      });

    return $id;
}

#----------------------------------------------------------------------------+
# get(\%controller, $name)

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

    my $id = $cookie ? $cookie : $name;

    my @servers   = $c->config->{memcached_servers};
    my $threshold = $c->config->{memcached_threshold} || 10_000;
    my $debug     = $c->config->{debug}               || 0;
    
    my %session;

    eval {

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

    my $id = $cookie ? $cookie : $name;

    my @servers   = $c->config->{memcached_servers};
    my $threshold = $c->config->{memcached_threshold} || 10_000;
    my $debug     = $c->config->{debug}               || 0;
    
    my %session;

    eval {

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

            Servers           => \@servers,
            NoRehash          => 1,
            Debug             => $debug,
            CompressThreshold => $threshold,
          };
      };

    unless ($@) {
        tied(%session)->delete;

        $c->plugin('Cookie')->delete($c, $name);
    }

    return;
}

#----------------------------------------------------------------------------+
# update(\%controller, $name, \%data);
#
# Takes the cookie unique identifier or session id as arguments.  Updates
# existing session data.

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  },
          { type => HASHREF }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

    my $id = $cookie ? $cookie : $name;

    my @servers   = $c->config->{memcached_servers};
    my $threshold = $c->config->{memcached_threshold} || 10_000;
    my $debug     = $c->config->{debug}               || 0;
    
    my %session;

    eval {

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    return $c->plugin('Cookie')->get($name);
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~[  PRIVATE METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# _init(\%params)
#
# Return a reference of $self to the caller.

sub _init {

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN


L<http://www.danga.com/memcached>

=head1 PREREQUISITES

This package is part of a larger distribution and was NOT intended to be used 
directly.  In order for this plugin to work properly, the following packages
must be installed:

  Apache2::WebApp
  Apache2::WebApp::Plugin::Cookie
  Apache2::WebApp::Plugin::Session
  Apache::Session::Memcached
  Apache::Session::Store::Memcached
  Params::Validate

=head1 INSTALLATION

From source:

  $ tar xfz Apache2-WebApp-Plugin-Session-Memcached-0.X.X.tar.gz

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

  [memcached]
  servers   = 127.0.0.1:11211, 10.0.0.10:11212, /var/sock/memcached
  threshold = 10_000

=head1 OBJECT METHODS

Please refer to L<Apache2::WebApp::Plugin::Session> for method info.

=head1 SEE ALSO

L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<Apache2::WebApp::Plugin::Cookie>,
L<Apache2::WebApp::Plugin::Memcached>, L<Apache2::WebApp::Plugin::Session>,
L<Apache::Session>, L<Apache::Session::Memcached>

=head1 AUTHOR

Marc S. Brooks, E<lt>mbrooks@cpan.orgE<gt> - L<http://mbrooks.info>

=head1 COPYRIGHT

This program is free software; you can redistribute it and/or modify it



( run in 0.525 second using v1.01-cache-2.11-cpan-e9199f4ba4c )