Closed flexdinesh closed 7 months ago
You can use https://github.com/mna/upstashdis
Looks like upstashdis is a Go client. @upstash/redis
supporting this out of the box would be nice. Asking as a feature request.
upstashdis is also a REST wrapper around redis.
But you would rather use an official solution, correct?
That's correct. Support by the Upstash team means that any breaking releases to @upstash/redis
would support both local redis and upstash redis instead of having to wait for a release if I used a third party package.
upstashdis is also a REST wrapper around redis.
upstashdis is good but I'm building with JavaScript. I don't think I can use upstashdis since it's a Go client.
I have the same issue. I'm going to try coding something to get a patch but first class support would be best!
export default class Redis {
client: UpstashRedis | RedisClientType;
static shared = new Redis();
constructor() {
if (process.env.NODE_ENV === 'production') {
this.client = createClient(
{
url: REDIS_SERVER_URL
}
);
} else {
this.client = new UpstashRedis(
{
url: UPSTASH_REDIS_SERVER_URL,
token: UPSTASH_REDIS_SERVER_TOKEN
}
);
}
}
set(key: string, value: string) {
if (this.client instanceof UpstashRedis) {
const client = this.client as UpstashRedis;
return client.set(key, value);
} else {
const client = this.client as RedisClientType;
return client.set(key, value);
}
}
get(key: string) {
if (this.client instanceof UpstashRedis) {
const client = this.client as UpstashRedis;
return client.get(key);
} else {
const client = this.client as RedisClientType;
return client.get(key);
}
}
}
That's the beginnings of a Redis & UpstashRedis abstraction. It suits my needs but feel free to clean it up, add what you need & use it yourself!
I had the if condition wrong:
if (process.env.NODE_ENV === 'production') {
this.client = new UpstashRedis(
{
url: UPSTASH_REDIS_SERVER_URL,
token: UPSTASH_REDIS_SERVER_TOKEN
}
);
} else {
this.client = createClient(
{
url: REDIS_SERVER_URL
}
);
}
I tried this last week @un-focused. This solution is good and works well enough as long as we don't need to use @upstash/ratelimit
in our code. When we do, the types are not compatible.
It'd be nice to have this officially supported by @upstash/redis
so packages like @upstash/ratelimit
just work without any extra abstractions.
As I said above, it is a wrapper around a running redis instance to expose an http server compatible with our API. It's not just a client.
upstash-redis-rest-server --addr <ADDR> --redis-addr <ADDR> [--api-token <TOKEN>]
But I do see your point. We'll discuss providing a first party redis wrapper internally.
Oh man I saw Go in their docs and mistook it for a go client. upstashdis is what I was looking for. Thanks for clearing it up @chronark and sorry about the confusion. 😀
Can this be reopened? Having an official wrapper would be ideal. It's hard to rely on a 3rd party tool for a service your org is paying for.
I'm afraid we currently don't have the capacity to build and support this. But I do see the value in an official wrapper
I could take a look at making one. What are the requirements?
I made a small one for my personal project a while ago and would be happy to make a new one and submit a Pull Request :)
we have't scoped it out yet
I think we'd like to offer a docker image that has an upstash compatible rest api and talks to any redis instance over tcp
Would be really helpful for local dev, this would also enable edge-flags locally 🔥 I don't always have good internet here in Perú so I prefer to have everything locally while developing
You can use Serverless Redis HTTP (SRH) to run a local HTTP endpoint for development. (See: https://docs.upstash.com/redis/sdks/javascriptsdk/developing-or-testing)
Just my two cents here as someone considering upstash for our caching. I'm sure I can just use SRH here, but it is a bummer this isn't a smoother experience. Because now you have to have to have Docker configured or go just to use @upstash/redis
locally. Since we aren't using Docker or Go, our install and setup process gets that much more brittle. Not that we're unwilling to add that setup, but there not being an official solution is a turn off of using upstash in general.
Alright, I'll chat with the team about this. We really value our community, so we'll work on making things smoother. Keep an eye out for updates.
I've been recently using @upstash/redis
, was developing for cloudflare-workers and bumped into similar issues. I ended up creating https://github.com/DarthBenro008/upstash-redis-local
You can simply docker run -p 8000:8000 darthbenro008/upstash-redis-local
or install even via homebrew
! No need to setup golang or docker separately.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity.
I'm working with Upstash for clients at our agency, I agree that this would be very helpful
I use
@upstash/redis
in my vercel serverless functions. I can connect to the databases created in Upstash console.Looks like the connection API is tailored to work wiht upstash redis server using http REST.
I would also like to be able to connect to my local redis server for local development. I don't really like the idea of sending requests over the network for local development. Using a different client for local development is not great either. So is there a way to run an upstash cluster in my local or connect to my local redis server using
@upstash/redis
?Eg. CockroachDB lets run their cluster locally in my machine so I don't have to build local only abstractions to work with CockroachDB.
It'd be nice to have something similar while working with Upstash.