envelop icon indicating copy to clipboard operation
envelop copied to clipboard

feat(response-cache): add response-cache-upstash

Open chronark opened this issue 3 years ago • 9 comments

Add redis cache using stateless HTTP connections instead of TCP with Upstash Redis.

Description

This is basically a copy of response-cache-redis where I changed a few details to make it work with @upstash/redis http client.

Implements #1218

Type of change

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  1. Create a free database on Upstash
  2. UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." yarn test

Test Environment:

  • OS: macOS 12.4
  • NodeJS: 16.15.0

Checklist:

  • [x] I have followed the CONTRIBUTING doc and the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented on my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules

Further comments

I haven't figured out why the tests are not passing yet, to me it seems unrelated to the implementation but I will take another look this week. It writes and reads from the cache but for some reason doesn't use the cache sometimes.

chronark avatar May 30 '22 06:05 chronark

Hey @chronark, tests here are currently failing because we are still running tests against Node.js version 12. After https://github.com/n1ru4l/envelop/pull/1417 is merged, you can rebase this branch. 😇

n1ru4l avatar Jun 09 '22 20:06 n1ru4l

@chronark We will delay dropping Node.js 12 support until The Yoga v3 launch (https://github.com/dotansimha/graphql-yoga/issues/1358). Is there an alternative (older) version of @upstash/redis, that still supports Node.js 12?

n1ru4l avatar Jul 11 '22 09:07 n1ru4l

Hmm, v1.3.0 or older might still work. But I'm not 100% sure. I won't have time this week but I'll add it to my todo list.

chronark avatar Jul 11 '22 10:07 chronark

⚠️ No Changeset found

Latest commit: fb47e92b305704ea6fd963315096fb29c5cc9f98

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 20 '22 14:07 changeset-bot[bot]

@chronark is attempting to deploy a commit to the The Guild Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 20 '22 14:07 vercel[bot]

@chronark hey, we dropped Node 12 support by now - do you mind rebasing this PR?

n1ru4l avatar Nov 22 '22 09:11 n1ru4l

@n1ru4l I'll put it on my todo list for this or next week thanks for letting me know

chronark avatar Nov 22 '22 10:11 chronark

Hey @chronark, that's a neat plugin. Could you please rebase this PR?

YassinEldeeb avatar Dec 12 '22 07:12 YassinEldeeb

Can't really get the tests to pass right now and I'm not sure why It definitely caches data to redis. I'll give this another shot tomorrow

chronark avatar Dec 12 '22 10:12 chronark