This demo uses Redis as a frontend cache for BigQuery. It demonstrates how to apply the cache prefetching strategy and use Redis for JSON storage and search. The app is written in Express and React with vite.
- gcloud credentials
- BigQuery setup with the Formula One dataset loaded
- bun
- docker
- Optional
Copy and edit the .env
file:
cp .env.example .env
Your .env
file should contain the connection string you copied from Redis Cloud. It also has the Google Cloud credentials for connecting to BigQuery.
- Copy the JSON from the generated
application_default_credentials.json
into your.env
file using theGOOGLE_APPLICATION_CREDENTIALS
variable - Set the
GOOGLE_CLOUD_PROJECT_ID
environment variable in your.env
file to the associated gcloud project you want to use.
Your .env.docker
file will overwrite the REDIS_URL to use the appropriate docker internal URLs. Here is
an example:
REDIS_URL="redis://redis:6379"
Next, spin up docker containers:
docker compose up -d --build
You should have a server running on http://localhost:<port>
where the port is set in your .env
file (default is 8080).
Visit the localhost url to see your site.
To run the development server outside of docker:
bun install
# then
bun dev
Formatting code:
bun format
If you don't yet have a database setup in Redis Cloud get started here for free.
To connect to a Redis Cloud database, log into the console and find the following:
- The
public endpoint
(looks likeredis-#####.c###.us-east-1-#.ec2.redns.redis-cloud.com:#####
) - Your
username
(default
is the default username, otherwise find the one you setup) - Your
password
(either setup through Data Access Control, or available in theSecurity
section of the database page.
Combine the above values into a connection string and put it in your .env
and .env.docker
accordingly. It should
look something like the following:
REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"
To learn more about Redis, take a look at the following resources:
- Redis Documentation - learn about Redis products, features, and commands.
- Learn Redis - read tutorials, quick starts, and how-to guides for Redis.