New NoSQL backend
This commit is contained in:
parent
d2549c2fbe
commit
d8b5a19c3f
|
@ -9,7 +9,7 @@ use Apache::Session::Serialize::Base64;
|
|||
#use Apache::Session::Serialize::Storable;
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '0.01';
|
||||
$VERSION = '0.02';
|
||||
|
||||
sub populate {
|
||||
my $self = shift;
|
||||
|
@ -38,7 +38,13 @@ Apache::Session::NoSQL - An implementation of Apache::Session module for NoSQL d
|
|||
|
||||
use Apache::Session::NoSQL;
|
||||
tie %hash, 'Apache::Session::NoSQL', $id, {
|
||||
# TODO
|
||||
Driver => 'Cassandra',
|
||||
|
||||
# or
|
||||
|
||||
Driver => 'Redis',
|
||||
# optional: default to 127.0.0.1:6379
|
||||
server => '10.1.1.1:6379',
|
||||
};
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
@ -49,10 +55,11 @@ to store datas.
|
|||
=head1 AUTHOR
|
||||
|
||||
Thomas Chemineau, E<lt>thomas.chemineau@gmail.comE<gt>
|
||||
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2010 by Thomas Chemineau
|
||||
Copyright (C) 2010 by Thomas Chemineau, Xavier Guimard
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.10.0 or,
|
||||
|
|
|
@ -3,7 +3,7 @@ package Apache::Session::Store::NoSQL;
|
|||
use strict;
|
||||
use vars qw(@ISA $VERSION);
|
||||
|
||||
$VERSION = '0.01';
|
||||
$VERSION = '0.02';
|
||||
|
||||
sub new {
|
||||
my ( $class, $session ) = @_;
|
||||
|
@ -16,7 +16,7 @@ sub new {
|
|||
if ($@) {
|
||||
die 'Unable to load ' . $module;
|
||||
}
|
||||
unless ( $self->{cache} = new $module ) {
|
||||
unless ( $self->{cache} = new $module ( $session->{args} ) ) {
|
||||
die 'Unable to instanciate ' . $module;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package Apache::Session::Store::NoSQL::Redis;
|
||||
|
||||
use strict;
|
||||
use Redis;
|
||||
|
||||
our $VERSION = '0.01';
|
||||
|
||||
sub new {
|
||||
my ( $class, $session ) = @_;
|
||||
my $self;
|
||||
|
||||
$self->{cache} = Redis->new( %{$session} );
|
||||
print STDERR Dumper(\@_);use Data::Dumper;
|
||||
|
||||
bless $self, $class;
|
||||
}
|
||||
|
||||
sub insert {
|
||||
my ( $self, $session ) = @_;
|
||||
$self->{cache}->set($session->{data}->{_session_id},$session->{serialized});
|
||||
}
|
||||
|
||||
*update = *insert;
|
||||
|
||||
sub materialize {
|
||||
my ( $self, $session ) = @_;
|
||||
$self->{cache}->get($session->{data}->{_session_id}) or die 'Object does not exist in data store.';
|
||||
}
|
||||
|
||||
sub remove {
|
||||
my ( $self, $session ) = @_;
|
||||
$self->{cache}->del($session->{data}->{_session_id});
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::Store::NoSQL::Redis - An implementation of Apache::Session::Store
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Apache::Session::NoSQL;
|
||||
|
||||
#if you want Apache::Session to open new DB handles:
|
||||
|
||||
tie %hash, 'Apache::Session::MySQL', $id, {
|
||||
Driver => 'Redis',
|
||||
# optional: default to localhost
|
||||
server => '127.0.0.1:6379',
|
||||
};
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module is an implementation of Apache::Session::NoSQL. It uses the Redis
|
||||
storage system
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Xavier Guimard <x.guimard@free.fr>
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Apache::Session::NoSQL>, L<Apache::Session>
|
Loading…
Reference in New Issue
Block a user