Quick Start Guide
Connecting to Redis
GoFr simplifies the process of connecting to Redis.
Setup:
Ensure we have Redis installed on our system.
Optionally, We can use Docker to set up a development environment with password authentication as described below.
docker run --name gofr-redis -p 2002:6379 -d \
-e REDIS_PASSWORD=password \
redis:7.0.5 --requirepass password
We can set a sample key greeting
using the following command:
docker exec -it gofr-redis bash -c 'redis-cli SET greeting "Hello from Redis."'
Configuration & Usage:
GoFr applications rely on environment variables to configure and connect to a Redis server.
These variables are stored in a .env
file located within the configs
directory at your project root.
Required Environment Variables:
Key | Description |
---|---|
REDIS_HOST | Hostname or IP address of your Redis server |
REDIS_PORT | Port number your Redis server listens on (default: 6379 ) |
REDIS_USER | Redis username; multiple users with ACLs can be configured. See official docs |
REDIS_PASSWORD | Redis password (required only if authentication is enabled) |
REDIS_DB | Redis database number (default: 0 ) |