Make better use of LMDB APIs

Use writeable mmap for write ops, use cursors to reduce seek
overhead, reuse read txn and cursor to avoid malloc overhead.

See the difference this makes here https://gist.github.com/hyc/38c9151cff21a3dc8bee