Database & Cache
StremThru supports SQLite and PostgreSQL for persistent storage, and Redis for caching.
Database
STREMTHRU_DATABASE_URI
URI for the database connection.
Format: <scheme>://<user>:<pass>@<host>[:<port>][/<db>]
- Default:
sqlite://./data/stremthru.db
Supported schemes:
| Scheme | Database |
|---|---|
sqlite | SQLite (default) |
postgresql | PostgreSQL |
Supported query parameters:
| Parameter | Description |
|---|---|
max_conns | Maximum number of connections |
min_conns | Minimum number of connections |
SQLite
TIP
SQLite is the recommended database for the vast majority of the users. You don't really need PostgreSQL.
SQLite is used by default with no configuration required. The database file is stored in the data directory.
STREMTHRU_DATABASE_URI=sqlite://./data/stremthru.dbPostgreSQL
To use PostgreSQL, set the database URI:
STREMTHRU_DATABASE_URI=postgresql://stremthru:stremthru@localhost:5432/stremthruWith connection pool configuration:
STREMTHRU_DATABASE_URI=postgresql://stremthru:stremthru@localhost:5432/stremthru?max_conns=20&min_conns=5A Docker Compose setup with PostgreSQL:
services:
stremthru:
image: muniftanjim/stremthru
ports:
- 8080:8080
environment:
STREMTHRU_DATABASE_URI: postgresql://stremthru:stremthru@postgres:5432/stremthru
depends_on:
- postgres
postgres:
image: postgres:16.6-alpine
environment:
POSTGRES_DB: stremthru
POSTGRES_USER: stremthru
POSTGRES_PASSWORD: stremthru
volumes:
- ./data/postgres:/var/lib/postgresql/dataSTREMTHRU_DATABASE_REPLICA_URIS
Comma-separated list of PostgreSQL replica URIs for read scaling. Only supported with PostgreSQL.
Format: Same as STREMTHRU_DATABASE_URI (PostgreSQL only)
Behavior:
- Read queries are routed to replicas
- Write queries and transactions use the primary
- Round-robin load balancing across replicas
- Falls back to primary if no replicas are configured
Example:
STREMTHRU_DATABASE_REPLICA_URIS=postgresql://stremthru:stremthru@replica1:5432/stremthru,postgresql://stremthru:stremthru@replica2:5432/stremthruCache
Redis
TIP
Redis is completely optional, it is not required for StremThru to function properly.
STREMTHRU_REDIS_URI
URI for Redis connection.
Format: redis://<user>:<pass>@<host>[:<port>][/<db>]
If provided, Redis is used for caching instead of in-memory storage.
Example:
STREMTHRU_REDIS_URI=redis://localhost:6379A Docker Compose setup with Redis:
services:
stremthru:
image: muniftanjim/stremthru
ports:
- 8080:8080
environment:
STREMTHRU_REDIS_URI: redis://redis:6379
depends_on:
- redis
redis:
image: redis:8-alpine