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

Support SQLite unflagged without useless warnings #3947

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,8 @@ module.exports.cacheStores = {
MemoryCacheStore: require('./lib/cache/memory-cache-store')
}

try {
const SqliteCacheStore = require('./lib/cache/sqlite-cache-store')
module.exports.cacheStores.SqliteCacheStore = SqliteCacheStore
} catch (err) {
// Most likely node:sqlite was not present, since SqliteCacheStore is
// optional, don't throw. Don't check specific error codes here because while
// ERR_UNKNOWN_BUILTIN_MODULE is expected, users have seen other codes like
// MODULE_NOT_FOUND
}
const SqliteCacheStore = require('./lib/cache/sqlite-cache-store')
module.exports.cacheStores.SqliteCacheStore = SqliteCacheStore

module.exports.buildConnector = buildConnector
module.exports.errors = errors
Expand Down
6 changes: 5 additions & 1 deletion lib/cache/sqlite-cache-store.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict'

const { DatabaseSync } = require('node:sqlite')
const { Writable } = require('stream')
const { assertCacheKey, assertCacheValue } = require('../util/cache.js')

let DatabaseSync

const VERSION = 3

// 2gb
Expand Down Expand Up @@ -101,6 +102,9 @@ module.exports = class SqliteCacheStore {
}
}

if (!DatabaseSync) {
DatabaseSync = require('node:sqlite').DatabaseSync
}
this.#db = new DatabaseSync(opts?.location ?? ':memory:')

this.#db.exec(`
Expand Down
Loading