Build from source
Toolchain, build targets and test targets.
Building pgredis from source compiles both the pg_redis PostgreSQL C extension and the pgredis Go gateway executable.
Toolchain
PostgreSQL 18Server binaries (initdb,pg_ctl,postgres,psql),pg_config, and server development headers (postgresql-server-dev-18on Debian/Ubuntu).Go 1.27.4Required to build the gateway and test harnesses.CGO_ENABLED=1is mandatory because the gateway uses libc host resolution forMIGRATE.C11 compilerclangorgcccompatible with the PostgreSQL PGXS build flags reported bypg_config.Python 3Used byscripts/prepare_pgx.py(which applies the local read-budget patch to the vendoredpgxcache) and by the reference/application test runners.
The gateway and both Go test modules require Go 1.27.4. Current source uses pgx v5.12.0 with the project’s read-budget and password-preparation patch; the v0.1.0-rc1 packages use v5.11.0. The Go client tests use go-redis v9.23.0.
Build the gateway and extension
Run the gateway build from the repository root, then compile and install the C extension with PGXS:
What each step produces:
make buildrunspython3 scripts/prepare_pgx.py, verifiesCGO_ENABLED=1, executesgo generate ./internal/gateway(which generates the command dispatch table fromspec/commands.json), and writes the gateway binary tobuild/pgredis.make -C extensioncompilesextension/pg_redis.cintoextension/pg_redis.soagainst the target PostgreSQL 18 headers.make -C extension installcopiespg_redis.so,pg_redis.control, andpg_redis--*.sql(0.1through0.54) into the PostgreSQL installation directories reported byPG_CONFIG.
Test targets
| Target | Command | Scope |
|---|---|---|
make test | go test ./cmd/... ./internal/... ./tests/integration/... ./tests/load/... ./tests/probes/... | Fast Go unit tests (RESP parser/writer, command table generation, SQL error probes) without a running PostgreSQL cluster. |
make test-integration | PGREDIS_INTEGRATION=1 go test -count=1 -v ... | Initializes a temporary PostgreSQL 18 cluster, installs pg_redis, and runs end-to-end gateway, SQL rollback, Pub/Sub, Streams, Blocking, and Tracking tests. |
make test-reference | python3 tests/reference/prepare.py && python3 tests/reference/run.py --mode external --variant prd | Builds the pinned Redis 7.2.4 reference binary (5221b82623c) and runs the upstream Tcl test harness against pgredis (requires tclsh). |
Repository layout
pgredis/
- cmd/pgredis/Gateway CLI entry point and flags
internal/
- gateway/Session router, tx/watch state, blocking, Pub/Sub, MIGRATE
- resp/Binary-safe RESP2 and RESP3 parser and serializer
extension/
- pg_redis.cC dispatcher, SPI plans, shared ring, background worker
- pg_redis.controlExtension metadata (default_version = '0.54')
- pg_redis--*.sqlBase schema (0.1) and upgrade scripts through 0.54
- patches/Local pgx v5.12.0 read-budget patch and earlier versions
- spec/commands.jsonRedis 7.2.4 command specification (392 commands)
- examples/outbox.sqlTransactional outbox SQL example
- tests/Integration, reference, client, application, and load suites
