Apache-Session-MongoDB
view release on metacpan or search on metacpan
lib/Apache/Session/MongoDB.pm view on Meta::CPAN
package Apache::Session::MongoDB;
use 5.010;
use strict;
use AutoLoader 'AUTOLOAD';
our $VERSION = '0.23';
our @ISA = qw(Apache::Session);
use Apache::Session;
use Apache::Session::Lock::Null;
use Apache::Session::Store::MongoDB;
use Apache::Session::Generate::MD5;
use Apache::Session::Serialize::MongoDB;
sub populate {
my $self = shift;
$self->{object_store} = Apache::Session::Store::MongoDB->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::MongoDB::serialize;
$self->{unserialize} = \&Apache::Session::Serialize::MongoDB::unserialize;
return $self;
}
our $default;
*default = \$Apache::Session::Store::MongoDB::default;
1;
__END__
sub searchOn {
my ( $class, $args, $selectField, $value, @fields ) = @_;
return $class->_query( $args, { $selectField => $value }, @fields );
}
sub searchOnExpr {
my ( $class, $args, $selectField, $value, @fields ) = @_;
$value =~ s/([\/\\\^\$\.\?\+\[\]\{\}\(\)])/\\$1/g;
$value =~ s/\*/\.\*/g;
return $class->_query( $args, { $selectField => qr/$value/i } );
}
sub deleteIfLowerThan {
my ( $class, $args, $rule ) = @_;
my $query;
if ( $rule->{or} ) {
$query = {
'$or' => [
map {
{ $_ => { '$lt' => $rule->{or}->{$_} } }
}
keys %{ $rule->{or} }
]
};
}
elsif ( $rule->{and} ) {
$query = {
'$and' => [
map {
{ $_ => { '$lt' => $rule->{or}->{$_} } }
}
keys %{ $rule->{or} }
]
};
}
if ( $rule->{not} ) {
$query = {
'$and' => [
$query,
map {
{ $_ => { '$ne' => $rule->{not}->{$_} } }
}
keys %{ $rule->{not} }
]
};
( run in 1.305 second using v1.01-cache-2.11-cpan-140bd7fdf52 )