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

feat(gatsby): Add cache-lmdb implementation #32373

Merged
merged 3 commits into from
Jul 15, 2021
Merged

feat(gatsby): Add cache-lmdb implementation #32373

merged 3 commits into from
Jul 15, 2021

Conversation

LekoArts
Copy link
Contributor

Description

When LMDB is used we now also use it for .cache/caches directory (now .cache/caches-lmdb). Some plugins put large data into this cache and keeps this stuff in memory. LMDB does everything our existing cache does but doesn't keep values in memory forever.

This cache also unlocks the possibility to write temporary query results to LMDB, too.

Related Issues

[ch34444]

@LekoArts LekoArts added the topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) label Jul 15, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 15, 2021
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 15, 2021
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Awesome! Looks good to me

cache = new GatsbyCacheLmdb({ name: `__test__` })
const fileDir = path.join(
process.cwd(),
`.cache/caches-lmdb-${process.env.JEST_WORKER_ID}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why you need to postfix it with worker id? Jest runs tests on multiple workers per file not test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this just clears the folder with the previous version of db. The actual path is set in cache-lmdb.ts and we need it in case if multiple tests use cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a little bit weird but I don't have enough context so 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not for this test alone. Other tests running in other processes may be writing/cleaning the same db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants