Skip to content

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 18 Server binaries (initdb, pg_ctl, postgres, psql), pg_config, and server development headers (postgresql-server-dev-18 on Debian/Ubuntu).
  • Go 1.27.4 Required to build the gateway and test harnesses. CGO_ENABLED=1 is mandatory because the gateway uses libc host resolution for MIGRATE.
  • C11 compiler clang or gcc compatible with the PostgreSQL PGXS build flags reported by pg_config.
  • Python 3 Used by scripts/prepare_pgx.py (which applies the local read-budget patch to the vendored pgx cache) 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:

make build
make -C extension PG_CONFIG=/path/to/pg_config
sudo make -C extension PG_CONFIG=/path/to/pg_config install

What each step produces:

  • make build runs python3 scripts/prepare_pgx.py, verifies CGO_ENABLED=1, executes go generate ./internal/gateway (which generates the command dispatch table from spec/commands.json), and writes the gateway binary to build/pgredis.
  • make -C extension compiles extension/pg_redis.c into extension/pg_redis.so against the target PostgreSQL 18 headers.
  • make -C extension install copies pg_redis.so, pg_redis.control, and pg_redis--*.sql (0.1 through 0.54) into the PostgreSQL installation directories reported by PG_CONFIG.

Test targets

TargetCommandScope
make testgo 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-integrationPGREDIS_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-referencepython3 tests/reference/prepare.py && python3 tests/reference/run.py --mode external --variant prdBuilds 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
Scan to open this page
https://mimus.pgsty.com/docs/redis/operations/build/

Table reader