Module Lmdb.Txn
Series of operations on an environment performed atomically.
type -'perm t
constraint '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 option
go perm env f
runs a transaction withperm
read/write permissions inenv
.The function
f txn
will receive the transaction handle. All changes to the environmentenv
done using the transaction handle will be persisted to the environment only whenf
returns. Afterf
returned, the transaction handle is invalid and should therefore not be leaked outsidef
.- returns
None
if the transaction was aborted withabort
, andSome _
otherwise.
- parameter txn
Create a child transaction to
txn
. This is not supported on anenv
withEnv.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 txn
aborts transactiontxn
and the currentgo
function, which will returnNone
.