Module Lmdb.Txn
Series of operations on an environment performed atomically.
type -'perm tconstraint 'perm = [< `Read | `Write ]A transaction handle. A transaction may be read-only or read-write.
val go : 'perm perm -> ?txn:'perm t -> Env.t -> ('perm t -> 'a) -> 'a optiongo perm env fruns a transaction withpermread/write permissions inenv.The function
f txnwill receive the transaction handle. All changes to the environmentenvdone using the transaction handle will be persisted to the environment only whenfreturns. Afterfreturned, the transaction handle is invalid and should therefore not be leaked outsidef.- returns
Noneif the transaction was aborted withabort, andSome _otherwise.
- parameter txn
Create a child transaction to
txn. This is not supported on anenvwithEnv.Flags.write_map.Here is an example incrementing a value atomically:
go rw env begin fun txn -> let v = Map.get ~txn k in Map.add ~txn k (v+1) ; v end
val abort : _ t -> _abort txnaborts transactiontxnand the currentgofunction, which will returnNone.