First of all, I wanted to thank you for developing and contributing to community this state of the art library!
I have couple of questions about the API. I did notÂ
1. I've noticed thatÂMDB_val contains "void*Âmv_data" and not "const void*".
Is there a reason for requiring non const pointers in this data structure?
I am asking because the c++ Âfunctions in my code that wrap lmdb API - they receive "const char* key" argument that I am either forced to forcefully const_cast the argument into void* or to strdup just to pass it into the API.
For put methods, it seems that at some point MDB must copy the data from mv_data to its storage soÂmv_data may beÂconst ptr in this case.
For get methods, MDB just changes the value of the pointer to point to its internal memory buffer and the clients should not change the contents of the buffer (I think) so again it can be const.
Am I wrong?
2. I do not completely understand how to use lmdb in multi-threaded environment . Is it correct to say that there can be only one open write transaction per MDB_env? In addition each thread can have at most one open transaction and this transaction is thread-local?
3. Is it possible to reuse dbi handle for all the transactions and all threads? In other words, is it possible at initialization step (when opening the database) to do the following:
Âmdb_env_open(env, "some_path", MDB_WRITEMAP | MDB_NOSYNC , 0664);
Âmdb_txn_begin(env, NULL, 0, &txn);
Âmdb_dbi_open(txn, NULL, 0, &dbi);
Âmdb_txn_commit(txn); Â // needed to keep dbi valid?
and then to use value of dbi for all the subsequent operations on that db?
Â ÂÂ Roman