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

Expose maxCacheSize opt (for system db) #156

Merged
merged 7 commits into from
Jun 24, 2024
Merged

Conversation

HDegroote
Copy link
Contributor

Note: the current implementation is not ideal for maintaining, given that the SystemView is created in 5 different places and it needs to be explicitly passed the maxCacheSize option every time. Might make sense to refactor to a createSystemView(core, length) method which is called in each of those 5 cases, where createSystemView is responsible for adding the opts (for now only maxCacheSize).

@mafintosh
Copy link
Contributor

Move the checkout to be an optional arg also so we dont have optional positionals

@HDegroote
Copy link
Contributor Author

Move the checkout to be an optional arg also so we dont have optional positionals

Done (I don't think SystemView is part of the public API, so should be fine, but in theory this is a breaking change)

lib/system.js Outdated
@@ -68,7 +70,13 @@ module.exports = class SystemView extends ReadyResource {
}

async checkout (length) {
const checkout = new SystemView(this.core.session(), length)
const checkout = new SystemView(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this was added with the last commit (had missed this usage of new SystemView on my initial pass, so it wasn't yet passing through the maxCacheSize)

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about making the opt explicit here?

Copy link
Contributor

Choose a reason for hiding this comment

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

checkout(length, { maxCacheSize = this.db.maxCacheSize } = {})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes sense. See #156 (comment) though, we might be iterating on a method that's no longer relevant

Copy link
Contributor

Choose a reason for hiding this comment

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

ok added it anyways

lib/system.js Outdated
@@ -12,12 +12,14 @@ const DIGEST = subs.sub(b4a.from([0]))
const MEMBERS = subs.sub(b4a.from([1]))

module.exports = class SystemView extends ReadyResource {
constructor (core, checkout = 0) {
constructor (core, opts = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

{ checkout = 0, maxCacheSize = 0 } = {}

lib/system.js Outdated
this.core.session(),
{
checkout: length,
maxCacheSize: this.maxCacheSize
Copy link
Contributor

Choose a reason for hiding this comment

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

dont think this prop is on the system, you should get it from the existing db

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, well-spotted, I fixed it.

I think that method is never used though (from what I can see, it's never used in autobase itself, nor is it tested, and I don't think it makes sense to access it directly from outside autobase), so might make sense to just remove it in a follow-up PR, or perhaps add a test

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh I think checkout will stick around for a while, it's quite useful to have

@chm-diederichs chm-diederichs merged commit 218d4ce into main Jun 24, 2024
4 checks passed
@chm-diederichs chm-diederichs deleted the max-cache-size-opt branch June 24, 2024 13:09
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.

3 participants