When developing or testing your application, you might not want or can not use
Upstash over the internet. In this case, you can use a community project called
Serverless Redis HTTP (SRH)
created by Scott Hiett.SRH is a Redis proxy and connection pooler that uses HTTP rather than the Redis
binary protocol. The aim of this project is to be entirely compatible with
Upstash, and work with any Upstash supported Redis version.We are working with Scott together to keep SRH up to date with the latest
Upstash features.
If you have a locally running Redis server, you can simply start an SRH
container that connects to it. In this example, SRH will be running on port
8080.
If you wish to run in Kubernetes, this should contain all the basics would need
to set that up. However, be sure to read the Configuration Options, because you
can create a setup whereby multiple Redis servers are proxied.
Copy
Ask AI
version: "3"services: redis: image: redis ports: - "6379:6379" serverless-redis-http: ports: - "8079:80" image: hiett/serverless-redis-http:latest environment: SRH_MODE: env SRH_TOKEN: example_token SRH_CONNECTION_STRING: "redis://redis:6379" # Using `redis` hostname since they're in the same Docker network.
SRH works nicely in GitHub Actions because you can run it as a container in a
job’s services. Simply start a Redis server, and then SRH alongside it. You
don’t need to worry about a race condition of the Redis instance not being
ready, because SRH doesn’t create a Redis connection until the first command
comes in.
Copy
Ask AI
name: Test @upstash/redis compatibilityon: push: workflow_dispatch:env: SRH_TOKEN: example_tokenjobs: container-job: runs-on: ubuntu-latest container: denoland/deno services: redis: image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version srh: image: hiett/serverless-redis-http:latest env: SRH_MODE: env # We are using env mode because we are only connecting to one server. SRH_TOKEN: ${{ env.SRH_TOKEN }} SRH_CONNECTION_STRING: redis://redis:6379 steps: # You can place your normal testing steps here. In this example, we are running SRH against the upstash/upstash-redis test suite. - name: Checkout code uses: actions/checkout@v3 with: repository: upstash/upstash-redis - name: Run @upstash/redis Test Suite run: deno test -A ./pkg env: UPSTASH_REDIS_REST_URL: http://srh:80 UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}
A huge thanks goes out to Scott for creating this project,
and for his continued efforts to keep it up to date with Upstash.