Module: LMDB
- Defined in:
- ext/lmdb_ext/lmdb_ext.c,
lib/lmdb/version.rb,
lib/lmdb/database.rb,
ext/lmdb_ext/lmdb_ext.c
Overview
The LMDB module presents a Ruby API to the OpenLDAP Lightning Memory-mapped Database (LMDB).
Defined Under Namespace
Classes: Cursor, Database, Environment, Error, Transaction
Constant Summary collapse
- VERSION =
'0.7.0'.freeze
- LIB_VERSION =
rb_str_new2(MDB_VERSION_STRING)
Class Method Summary collapse
-
.new(path, opts) {|env| ... } ⇒ Environment
Open an LMDB database environment.
Class Method Details
.new(path, opts) {|env| ... } ⇒ Environment
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'ext/lmdb_ext/lmdb_ext.c', line 620 static VALUE environment_new(int argc, VALUE *argv, VALUE klass) { VALUE path, option_hash; #ifdef RB_SCAN_ARGS_KEYWORDS rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS, argc, argv, "1:", &path, &option_hash); #else rb_scan_args(argc, argv, "1:", &path, &option_hash); #endif EnvironmentOptions = { .flags = MDB_NOTLS, .maxreaders = -1, .maxdbs = 128, .mapsize = 0, .mode = 0755, }; if (!NIL_P(option_hash)) rb_hash_foreach(option_hash, (int (*)(ANYARGS)), (VALUE)&); MDB_env* env; check(mdb_env_create(&env)); Environment* environment; VALUE venv = Data_Make_Struct(cEnvironment, Environment, environment_mark, environment_free, environment); environment->env = env; environment->thread_txn_hash = rb_hash_new(); environment->txn_thread_hash = rb_hash_new(); if (.maxreaders > 0) check(mdb_env_set_maxreaders(env, .maxreaders)); if (.mapsize > 0) check(mdb_env_set_mapsize(env, .mapsize)); check(mdb_env_set_maxdbs(env, .maxdbs <= 0 ? 1 : .maxdbs)); VALUE = (path, Qnil); check(mdb_env_open(env, StringValueCStr(), .flags, .mode)); if (rb_block_given_p()) return rb_ensure(rb_yield, venv, environment_close, venv); return venv; } |