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 theUPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
for
the next steps.
Project Setup
Create a folder for your project, runnpm init
inside. Then install Upstash
client with: npm install @upstash/redis
The Code
Updateindex.js
as below:
Run and Deploy
Deploy your function to Google Cloud with: