-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
There was a problem hiding this 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}` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly did that because that's how the class uses itself: https://github.com/gatsbyjs/gatsby/pull/32373/files#diff-efecbacd93ffd4230b01b2b38d8e9ab6b06f723b31146e8a3f08e747123a885aR11
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
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]