unstorage
unstorage copied to clipboard
feat: add `upstash-redis` driver
π Linked issue
Resolves https://github.com/unjs/unstorage/issues/288
β Type of change
- [ ] π Documentation (updates to the documentation, readme, or JSdoc annotations)
- [ ] π Bug fix (a non-breaking change that fixes an issue)
- [ ] π Enhancement (improving an existing functionality like performance)
- [x] β¨ New feature (a non-breaking change that adds functionality)
- [ ] π§Ή Chore (updates to the build process or auxiliary tools and libraries)
- [ ] β οΈ Breaking change (fix or feature that would cause existing functionality to change)
π Description
This PR adds a upstash-redis driver for redis support on edge platforms.
For full context, when vercel-kv was added in https://github.com/unjs/unstorage/pull/213, @redis/upstash was added as a dependency because it is a vercel-kv dependency, so that makes it easier for pnpm users.
This PR adds a redis-upstash driver for the use case where you want to use upstash without vercel (which I encountered recently)
The tests are running locally, and need env variables to work in the CI. We should create an unjs upstash db, or mock the client.
π Checklist
- [x] I have linked an issue or discussion.
- [x] I have updated the documentation accordingly.
Codecov Report
Merging #289 (ba6ea2d) into main (60159a5) will decrease coverage by
0.60%. Report is 3 commits behind head on main. The diff coverage is52.50%.
:exclamation: Current head ba6ea2d differs from pull request most recent head c370cbd. Consider uploading reports for the commit c370cbd to get more accurate results
@@ Coverage Diff @@
## main #289 +/- ##
==========================================
- Coverage 77.96% 77.37% -0.60%
==========================================
Files 29 30 +1
Lines 3418 3496 +78
Branches 521 522 +1
==========================================
+ Hits 2665 2705 +40
- Misses 752 790 +38
Partials 1 1
| Files | Coverage Ξ | |
|---|---|---|
| src/types.ts | 100.00% <100.00%> (ΓΈ) |
|
| src/drivers/redis-upstash.ts | 51.89% <51.89%> (ΓΈ) |
Hey there! (disclaimer: I work for upstash)
quick question: why did you install @vercel/kv and then use @upstash/redis
It seems to work cause their package is just a wrapper around @upstash/redis but it seemed weird :D
secondly: we can provde a db for unit tests for free, just let me know :)
Hey there! (disclaimer: I work for upstash)
quick question: why did you install
@vercel/kvand then use@upstash/redisIt seems to work cause their package is just a wrapper around@upstash/redisbut it seemed weird :Dsecondly: we can provde a db for unit tests for free, just let me know :)
Hello there! @vercel/kv is already a driver supported by unstorage, this PR doesn't install it. I didn't know their package was just a wrapper.
On providing us with a DB, I think that would be great ! @pi0 is the maintainer of unstorage, so he'll need to green light this
Do you mind resolving the conflicts @Hebilicious ?
Do you mind resolving the conflicts @Hebilicious ?
Sure. For full context, when vercel-kv was added in https://github.com/unjs/unstorage/pull/213, @redis/upstash was added as a dependency because it is a vercel-kv dependency, so that makes it easier for pnpm users to use unstorage without shamefully-hoist.
This PR adds a redis-upstash driver for the use case where you want to use upstash without vercel (which I encountered recently)
I'll add this to the PR description.
Hi dear @chronark thanks for reaching out and for your offer about the CI plan.
I would ideally love to have a proper "unit" test for both drivers. I think we can mock the HTTP client with upstash API. If you have a tool or package that can help in this regard it would be awesome! Also, feel free to reach me via discord (pi0) if you would like to work closer on upstash integrations I can invite you to the unjs discord channel.
Off topic: Regarding vercel-kv, the main reason for having a wrapper is that it allows having "zero configuration" integration with their platform / provided environment variables - also any changes needed in the future. If there are other hosting options that provided upstash integration, we probably have to either use their packages or make a wrapper driver.
Thanks for the updates @Hebilicious β€οΈ
@pi0 we don't have any true unit test library or similar, I'm running all of our tests against a real upstash db or in a docker container :/
I'm leaving upstash soon, joining your discord now probably won't help much unfortunately.
if you want credits for testing against real dbs, just let us know here: [email protected] and ideally reference this comment :D