···
has 'collection' => ( is => 'ro', isa => 'MongoDB::Collection' );
has 'db_name' => ( is => 'ro', isa => 'Str', default => 'chi' );
has 'safe' => ( is => 'rw', isa => 'Bool', default => 0 );
-
has 'use_oid' => ( is => 'rw', isa => 'Bool', default => 0 );
__PACKAGE__->meta->make_immutable();
···
-
? MongoDB::OID->new( value => unpack( "H*", $key ) )
my $results = $self->collection->find_one( { _id => $key }, { data => 1 } );
return ($results) ? $results->{data} : undef;
···
my ( $self, $key, $data ) = @_;
-
? MongoDB::OID->new( value => unpack( "H*", $key ) )
$self->collection->save( { _id => $key, data => $data },
{ safe => $self->{safe} } );
···
-
? MongoDB::OID->new( value => unpack( "H*", $key ) )
$self->collection->remove( { _id => $key }, { safe => $self->{safe} } );
···
-
return ( !shift->{use_oid} )
-
? map { $_->{_id} } shift->collection->find( {}, { _id => 1 } )->all
-
: croak 'Cannot get keys when converting keys to OID';
···
Optional flag to confirm insertion/removal. This will slow down writes significantly.
-
Optional flag to convert key to OID. This speeds up gets, slows retrieval, and removes the ability to get_keys.
···
has 'collection' => ( is => 'ro', isa => 'MongoDB::Collection' );
has 'db_name' => ( is => 'ro', isa => 'Str', default => 'chi' );
has 'safe' => ( is => 'rw', isa => 'Bool', default => 0 );
__PACKAGE__->meta->make_immutable();
···
my $results = $self->collection->find_one( { _id => $key }, { data => 1 } );
return ($results) ? $results->{data} : undef;
···
my ( $self, $key, $data ) = @_;
$self->collection->save( { _id => $key, data => $data },
{ safe => $self->{safe} } );
···
$self->collection->remove( { _id => $key }, { safe => $self->{safe} } );
···
+
map { $_->{_id} } shift->collection->find( {}, { _id => 1 } )->all;
···
Optional flag to confirm insertion/removal. This will slow down writes significantly.