Skip to content

Commit

Permalink
Improve batch docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LuKks committed Jun 29, 2023
1 parent 191e0ad commit bc7dec7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ Make a new atomic batch that is either fully processed or not processed at all.

If you have several inserts and deletions then a batch can be much faster.

Batch is snapshotted at creation. Outside writes are not taken into account when reading.

#### `await batch.lock()`

Force acquire the single write lock of the Hyperbee.

Otherwise, it's auto-acquired when you do the first `put` or `del` in a batch.

If lock was somehow acquired, then flush or close the batch so outside writes can be processed.

#### `await batch.put(key, [value], [options])`

Insert a key into a batch.
Expand All @@ -186,11 +196,11 @@ Delete a key into the batch.

#### `await batch.flush()`

Commit the batch to the database.
Commit the batch to the database, and releases any locks it has acquired.

#### `batch.destroy()`
#### `await batch.close()`

Destroy a batch and releases any locks it has aquired on the db.
Close a batch, and releases any locks it has acquired on the db.

Call this if you want to abort a batch without flushing it.

Expand Down

0 comments on commit bc7dec7

Please sign in to comment.