Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve batch docs #126

Merged
merged 5 commits into from
Jun 29, 2023
Merged

Improve batch docs #126

merged 5 commits into from
Jun 29, 2023

Conversation

LuKks
Copy link
Contributor

@LuKks LuKks commented Jun 29, 2023

Thanks @HDegroote the initial explanation: 08a3fca
I didn't even know that we had a lock method lol

README.md Outdated
@@ -168,6 +168,14 @@ 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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not highly true:

const batch = await db.batch()
t.is(batch.version, 1)
await db.put('/a')
t.is(batch.version, 2)
console.log(await batch.get('/a')) // => { seq, key, value }

So state is not snapshotted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A put (obvs) updates the snap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a db.put external write outside of batch, is that intended to update the snap of the batch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah db my bad. I'd prefer to leave this be for now. Its due to update being called. This needs some (breaking) refactor to remove all update calls

README.md Outdated Show resolved Hide resolved
@mafintosh mafintosh merged commit 311c840 into main Jun 29, 2023
@mafintosh mafintosh deleted the batch-docs branch June 29, 2023 15:21
@LuKks LuKks mentioned this pull request Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants