Caching Setup
How to setup caching in your project
Lytix support BYOC (Bring Your Own Cache) for Postgres. This allows you to own your cache data and query it independently of Lytix.
Integrations
Click below on the integration you’d like to use.
💽 Supabase
You can use a Supabase Postgres database as your cache store. Follow the steps below to get started.
1) Enable pg_cron
Extension
First we have to enagble the pg_cron
extension for our database. Follow instructions outlined here.
2) Get Your Database URL
You can get your database URL by following these instructions here. To summarize:
- Navigate to your project in the Supabase console
- Click on the
Settings
action - Click
Database
- Copy the ‘Connection String’ value. Remember to add your password here!
Note You need to add ?pooler=true
to the end of your database URL. See Github issue here
And you’re all setup getting a new Postgres database.
🐳 Docker
You can also build and host a PSQL docker container to host your cache database. We’ve already created a Dockerfile
for you to get started that includes the pg_cron
extension.
1) Copy the Repository
First copy the repository from Github.
2) Build the Docker Image
3) Run the Docker Container
4) Host the Docker Container
You can now host the docker container on a cloud service like AWS, GCP or Azure. After getting a database URL you can follow the steps below to provision the database.
Provision The Postgres Database
Provision script
Prerequisite You will need to download this shell script.
We now can use this shell script to provision a new Postgres database along with setting up our cron job logic.
Set your Cache Database URL
You can now upload your cache database URL on the Lytix UI here (or here for 🇪🇺).
And you’re all set up! 🎉