CHI-Driver-LMDB

 view release on metacpan or  search on metacpan

lib/CHI/Driver/LMDB.pm  view on Meta::CPAN

CHI::Driver::LMDB - use OpenLDAPs LMDB Key-Value store as a cache backend.

=head1 VERSION

version 0.002004

=head1 SYNOPSIS

  use CHI;

  my $cache = CHI->new(
    driver => 'LMDB',
    root_dir => 'some/path',
    namespace => "My::Project",
  );

See L<C<CHI> documentation|CHI> for more details on usage.

=head1 ATTRIBUTES

=head2 C<dir_create_mode>

What mode (if any) to use when creating C<root_dir> if it does not exist.

  ->new(
    # Default is 775 = rwxr-xr-x
    dir_create_mode => oct 666,
  );

=head2 C<root_dir>

The prefix directory the C<LMDB> data store will be installed to.

  ->new(
    root_dir => 'some/path'
  )

Default is:

  OSTEMPDIR/chi-driver-lmdb-$EUID

=head2 C<cache_size>

The size in bytes for each database.

This is a convenience wrapper for L</mapsize> which supports suffixes:

  cache_size => 5  # 5 bytes
  cache_size => 5k # 5 Kilobytes
  cache_size => 5m # 5 Megabytes ( default )

This is also designed for syntax compatibility with L<< C<CHI::Driver::FastMmap>|CHI::Driver::FastMmap >>

=head2 C<single_txn>

  single_txn => 1

B<SPEED>: For performance benefits, have a single transaction
that lives from the creation of the CHI cache till its destruction.

However, B<WARNING:> this flag is currently a bit dodgy, and CHI caches being kept alive
till global destruction B<WILL> trigger a C<SEGV>, and potentially leave your cache broken.

You can avoid this by manually destroying the cache with:

  undef $cache

Prior to global destruction.

=head2 C<db_flags>

Flags to pass to C<OpenDB>/C<< LMDB_File->open >>.

See L<< C<LMDB_File>'s constructor options|LMDB_File/LMDB_File >> for details.

  use LMDB_File qw( MDB_CREATE );

  db_flags => MDB_CREATE # default

=head2 C<tx_flags>

Flags to pass to C<< LMDB::Env->new >>

See L<< C<LMDB::Env>'s constructor options|LMDB_File/LMDB::Env >> for details.

Default is C<0>

  tx_flags => 0 # no flags

=head2 C<put_flags>

Flags to pass to C<< ->put(k,v,WRITE_FLAGS) >>.

See L<< LMDB_File->put options|LMDB_File/LMDB_File >> for details.

=head2 C<mapsize>

Passes through to C<< LMDB::Env->new( mapsize => ... ) >>

Default value is taken from L</cache_size> with some C<m/k> math if its set.

=head2 C<maxreaders>

Passes through to C<< LMDB::Env->new( maxreaders => ... ) >>

=head2 C<maxdbs>

Passes through to C<< LMDB::Env->new( maxdbs => ... ) >>

Defines how many CHI namespaces ( Databases ) a path can contain.

Default is 1024.

=head2 C<mode>

Passes through to C<< LMDB::Env->new( mode => ... ) >>

Defines the permissions on created DB Objects.

Defaults to C<oct 600> == C<-rw------->



( run in 1.649 second using v1.01-cache-2.11-cpan-df04353d9ac )