NAME
Geo::SpatialDB::Storage::LMDB_Storable - Key/value storage on LMDB, encoding Perl objects with 'Storable'
VERSION
version 0.000_001
DESCRIPTION
Storage engine LMDB_Storable uses (as the name implies) Storable to serialize perl data structures, and LMDB (via the LMDB_File module) for disk storage. I *think* this is the fastest possible way to persist Perl objects, but if you find something faster, I'd love to hear about it.
ATTRIBUTES
path
The path for the LMDB files. If this is an existing directory, LMDB will be initialized in the standard manner. But if it is a file (or missing) then we treat it as the database file itself, which means the directory must be writable in order for LMDB to create the lock file along side of it.
readonly
Boolean. If true, then open the DB in readonly mode. Useful for read-only filesystems.
mapsize
The maximum size of the database; default is 3GB. (LMDB needs this parameter)
run_with_scissors
If set to 1, then enable unsafe behavior in order to get some extra speed. Useful for large batch operations where the database can be thrown away if the operation fails catastrophically.
METHODS
get
my $value= $stor->get( $key );
Get the value of a key, or undef if the key doesn't exist.
put
$stor->put( $key, $value );
Store a value in the database. If the key exists it will overwrite the old value. If $value
is undefined, this deletes the key from the database.
commit, rollback
$stor->commit()
# - or -
$stor->rollback()
All 'get' or 'put' operations operate under an implied transaction. If you want to save your changes, or get a fresh view of the database to see concurrent changes by other processes, you need to call 'commit' or 'rollback'.
iterator
my $i= $stor->iterator;
# or
my $i= $stor->iterator( $from_key );
# then...
while (my $k= $i->()) { ... }
# or
while (my ($k, $v)= $i->()) { ... }
Return a coderef which can iterate keys or key,value pairs. If you specify $from_key
, then iteration begins at the first key equal or greater to it.
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.