blob: bd19045db1848c134fe9e16d2f0e355b19ddabaa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# [LMDB](http://www.lmdb.tech/doc/index.html) bindings for lua
license: MIT
## errors
operations that can fail will return `nil, error, errno` on failure.
## functions
### `lmdb.open(path, opt)`
create a new environment handle and open the database at the `path`. returns the environment handle (`env`) on success.
`opt` is an optional table of options:
* `maxdbs`: number: the maximum number of databases in the environment. must be set if multiple databases will be used.
* `rdonly`: boolean: open the environment in read-only mode.
* `nosubdir`: boolean: the `path` is used for the database file itself and not its containing directory.
* `nosync`: boolean: don't flush buffers to disk when committing.
* `nolock`: boolean: turn off locking. the application must manage all concurrency.
### `lmdb.version()`
returns the LMDB version as `major, minor, patch`.
### `env:txn_begin(rdonly)`
create a new transaction in the environment. if `rdonly` is true, then the transaction is not to be used to perform write operations. returns the transaction handle (`txn`) on success.
### `env:copy(path)`
copy the environment to the specified `path`. return `true` on success.
### `env:sync(force)`
flush buffers to disk. if `force` is `true`, a synchronous flush is performed even if `nosync` is set. return `true` on success.
### `env:close()`
close the environment.
### `txn:open(name, create)`
open a database in the environment. if multiple databases are to be used in the environment, `name` is the name of the database to open. otherwise, it should not be supplied. if `create` is true, the database is created if it does not exist. returns a database handle on success.
the database handle behaves as a table that may be indexed with string keys and contains string values, read from the database. any changes made will be saved to the database when the transaction is committed.
### `txn:drop(name)`
delete the database `name` from the environment. (or clear the database, if `name` is not supplied)
### `txn:abort()`
abandon all operations performed in the transaction.
### `txn:commit()`
commit all operations of the transaction into the database.
### `txn:txn_begin(rdonly)`
create a nested transaction in the parent transaction.
|