Google Cloud Functions
This tutorial uses @upstash/redis which is designed for serverless runtimes for efficient connection handling. You can use your favorite Redis client, but you may have to deal with connection issues as described here.
Database Setup
Create a Redis database using Upstash Console or
Upstash CLI. Select the GCP US-Central-1 as
the region. Copy the UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
for
the next steps.
Project Setup
Create a folder for your project, run npm init
inside. Then install Upstash
client with: npm install @upstash/redis
The Code
Update index.js
as below:
Run and Deploy
Deploy your function to Google Cloud with:
You will see the URL of your Cloud Function. Click to the URL to check if it is working properly.
In case of an issue, you can check the logs of your Cloud Function in the GCP console as below.
Was this page helpful?