-
Notifications
You must be signed in to change notification settings - Fork 130
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 Upstash Redis REST SDK in useResponseCache with Redis cache as store #1218
Comments
@dthyresson You can instantiate a new client as here Pipeline will be supported by SDK soon (in ~2 weeks) |
Thanks! I completely missed those docs. I’ll keep a watch for pipeline support since with that I think can just drop in the Upstash client and be good to go. Currently the pipeline command is used. |
I’ll keep this issue open as a reminder but I think it can become an issue to add documentation for using the Upstash Sdk instead. |
Hi @enesakar I recently got back into trying out GraphQL response caching with the
in I Need to do some investigation, but currently looking at: Where set is used in a pipeline. Also looking at: https://docs.upstash.com/redis/features/restapi#pipelining |
Hey @dthyresson Judging from the readme example, I should probably just create another package that exports So you would use it like this: import { envelop } from '@envelop/core';
import { useResponseCache } from '@envelop/response-cache';
import { createUpstashCache } from '@envelop/response-cache-upstash';
import { Redis } from "@upstash/redis"
const cache = createUpstashCache(Redis.fromEnv());
const getEnveloped = envelop({
plugins: [
// ... other plugins ...
useResponseCache({ cache }),
],
}); Please let me know what you think and I'll implement it afterwards |
@chronark Now that you mention the iodredis client in the package I was trying to use, this all makes so much sense why it wasn't working -- no idea why that didn't occur to me. :) I had a 🤦♂️ moment for sure. A dedicated Upstash Redis client would be great and I know I'd want to use it. Happy to help with implementation and testing as well. |
Hey @dthyresson I've created a draft PR #1404 |
Hi. I'll try too look too as well but Tim from the RedwoodJS community has offered to help as well; see: https://community.redwoodjs.com/t/guide-power-of-graphql-caching/2624/21?u=dthyresson |
Hi @chronark, is upstash still planning on adding support for this or is it on the back-burner for now? We'd definitely be interested in using upstash if this was production-ready. |
@akashkashyap a PR is here, currently it needs passing tests: #1404 (comment) |
Hey @akashkashyap unfortunately I got completely stuck on making the tests work |
Currently,
useReponseCache
offers a LRU and a Redis cache option.The redis-cache relies on
ioredis
as seen here: https://github.com/dotansimha/envelop/blob/cdb32401bc385ca4d3503c4bc6b23ddb1a5909c6/packages/plugins/response-cache-redis/src/redis-cache.ts#L1And then any gets, sets, keys, or smember checks use the Redis client; for example:
Describe the solution you'd like
Upstash is a serverless database service compatible with Redis® API.
They offer a REST API and a Javascript SDK: https://docs.upstash.com/redis/features/javascriptsdk
The advantage of this over a Redis client in the serverless world (where your GraphQL queries will be done in a Lambda like with RedwoodJS) is that it's less likely to run into connection limits. Other Redis offerings have 10, 20, 40 connections and base pricing on that where with Upstash the pricing is per usage.
Also, the Rest client works well on the Edge in a Netlify or Vercel edge handler/function.
However, because the current cache implementation needs a client to invoke
get
etc, one cannot easily use the Upstash SDK:For example (their sample code):
Notice that here
set
is a method, but not likestore.set()
on the client.Perhaps create another redis cache that uses Upstash specifically?
Would this be part of https://github.com/dotansimha/envelop/tree/main/packages/plugins/response-cache-redis/src or an entirely new plugin just for Upstash?
Other
Or, perhaps there is a way to modify the SDK such that there is a client that can be imported (here? https://github.com/upstash/upstash-redis/blob/master/src/index.ts) and then the plugin can have as is?
pipeline
but not 100% certain if the SDK does.Additional context
The text was updated successfully, but these errors were encountered: