-
Notifications
You must be signed in to change notification settings - Fork 112
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
feature: add sqlite storage #21
base: master
Are you sure you want to change the base?
Conversation
I think an improvement here would be to make the table name configurable, or make it something much less likely to have a collision |
🦋 Changeset detectedLatest commit: bd9ce7b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
made some changes but i think TTL is not respected? |
Added one liner to cleanup expired rows on get/scan. Do we need something similar for memory storage as well to cleanup expired values? |
sorry i should have been more explicit i don't think we should run a cleanup on every call - i meant when we do a similarly with scan, if we come across an expired value we should delete it it's not necessary so i'll merge even without that just as long as the adapter is not returning expired values |
btw i just pushed a basic set of tests, maybe can try them with the sql adapter |
const TABLE_NAME = input?.tableName ?? "__openauth__kv_storage"; | ||
|
||
db.exec( | ||
`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (key TEXT PRIMARY KEY, value TEXT, expiry INTEGER)` |
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.
expiry is a separate column instead of being part of the value, as it's relatively easier to query.
let storage = SQLiteStorage(); | ||
|
||
beforeEach(async () => { | ||
storage = SQLiteStorage(); |
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 pretty much the same as memory storage test
Adds sqlite storage option using libsql. better-sqlite3 doesn't play well with bun.
Fixes #11