blob: c01d7177092eba614c9f94d67b9f25c88ba528fc (
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
|
local lmdb = require 'lmdb'
local M = {}
local db
function M.get()
if not db then
db = assert(lmdb.open("data", {maxdbs = 256}))
end
local txn = db:txn_begin(true)
local meta = txn:open("meta", true)
if not meta.version then
version = 1
end
txn:open("users", true)
txn:open("usernames", true)
txn:open("emails", true)
txn:commit()
return db
end
function M.txn(write_enabled)
return M.get():txn_begin(write_enabled)
end
M.next = lmdb.next
return M
|