Redis Cache
The REDIS strategy stores cached data in Redis. The cache persists across restarts and can be shared between multiple application instances. It supports TTL-based expiration, optional TLS, and compression (GZIP or BROTLI).
This is ideal for self-hosted production deployments that need shared, persistent cache without relying on a CDN.
Set the strategy in the Runtime block of your gothic.config.go file:
Runtime: gothic.RuntimeConfig{
CacheStrategy: gothic.REDIS,
ServeStaticFiles: gothic.ALL_ENVS,
CacheConfig: &gothic.CacheConfig{
RedisURL: "localhost:6379",
RedisPassword: "your-password",
RedisTLS: false,
},
},The CacheConfig fields for Redis are: RedisURL — the Redis server address (e.g. localhost:6379), RedisPassword — authentication password, and RedisTLS — enable TLS for encrypted connections. You can also enable Compression and choose between GZIP (default) and BROTLI.
Here is a docker-compose.yml example for self-hosted deployments with Redis:
version: "3.8"
services:
app:
build: .
ports:
- "8080:8080"
environment:
- HTTP_LISTEN_ADDR=:8080
- REDIS_URL=redis:6379
depends_on:
- redis
redis:
image: redis:7-alpine
ports:
- "6379:6379"Want persistent cache without external dependencies? Check out the Local Files cache strategy!
