Skip to content

redis

Send redis pub/sub messages to Redis from PostgreSQL Directly

pg_redis_pubsub · Send redis pub/sub messages to Redis from PostgreSQL Directly

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
8720redispg_redis_pubsub0.0.1FDWMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.0.119 18 17 16 15pg_redis_pubsub-
RPMPIGSTY0.0.119 18 17 16 15pg_redis_pubsub_$v-
DEBPIGSTY0.0.119 18 17 16 15postgresql-$v-pg-redis-pubsub-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el8.aarch64N/APIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el9.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el9.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el10.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
el10.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d12.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d12.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d13.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
d13.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u22.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u22.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u24.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u24.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u26.x86_64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
u26.aarch64PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1PIGSTY 0.0.1
PackageVersionOSORGSIZEFile URL
pg_redis_pubsub_190.0.1el9.x86_64pigsty20.4 KiBpg_redis_pubsub_19-0.0.1-1PGSTY.el9.x86_64.rpm
pg_redis_pubsub_190.0.1el9.aarch64pigsty20.2 KiBpg_redis_pubsub_19-0.0.1-1PGSTY.el9.aarch64.rpm
pg_redis_pubsub_190.0.1el10.x86_64pigsty20.4 KiBpg_redis_pubsub_19-0.0.1-1PGSTY.el10.x86_64.rpm
pg_redis_pubsub_190.0.1el10.aarch64pigsty20.5 KiBpg_redis_pubsub_19-0.0.1-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-redis-pubsub0.0.1d12.x86_64pigsty12.4 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-redis-pubsub0.0.1d12.aarch64pigsty12.4 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-redis-pubsub0.0.1d13.x86_64pigsty12.3 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~trixie_amd64.deb
postgresql-19-pg-redis-pubsub0.0.1d13.aarch64pigsty12.4 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~trixie_arm64.deb
postgresql-19-pg-redis-pubsub0.0.1u22.x86_64pigsty12.7 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~jammy_amd64.deb
postgresql-19-pg-redis-pubsub0.0.1u22.aarch64pigsty12.6 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~jammy_arm64.deb
postgresql-19-pg-redis-pubsub0.0.1u24.x86_64pigsty12.9 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~noble_amd64.deb
postgresql-19-pg-redis-pubsub0.0.1u24.aarch64pigsty12.9 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~noble_arm64.deb
postgresql-19-pg-redis-pubsub0.0.1u26.x86_64pigsty12.9 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~resolute_amd64.deb
postgresql-19-pg-redis-pubsub0.0.1u26.aarch64pigsty13.0 KiBpostgresql-19-pg-redis-pubsub_0.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_redis_pubsub_180.0.1el8.x86_64pigsty20.1 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el8.x86_64.rpm
pg_redis_pubsub_180.0.1el8.aarch64pigsty20.2 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el8.aarch64.rpm
pg_redis_pubsub_180.0.1el9.x86_64pigsty20.4 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el9.x86_64.rpm
pg_redis_pubsub_180.0.1el9.aarch64pigsty20.2 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el9.aarch64.rpm
pg_redis_pubsub_180.0.1el10.x86_64pigsty20.4 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el10.x86_64.rpm
pg_redis_pubsub_180.0.1el10.aarch64pigsty20.5 KiBpg_redis_pubsub_18-0.0.1-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-redis-pubsub0.0.1d12.x86_64pigsty12.4 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-redis-pubsub0.0.1d12.aarch64pigsty12.4 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-redis-pubsub0.0.1d13.x86_64pigsty12.3 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~trixie_amd64.deb
postgresql-18-pg-redis-pubsub0.0.1d13.aarch64pigsty12.4 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~trixie_arm64.deb
postgresql-18-pg-redis-pubsub0.0.1u22.x86_64pigsty12.7 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~jammy_amd64.deb
postgresql-18-pg-redis-pubsub0.0.1u22.aarch64pigsty12.6 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~jammy_arm64.deb
postgresql-18-pg-redis-pubsub0.0.1u24.x86_64pigsty12.9 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~noble_amd64.deb
postgresql-18-pg-redis-pubsub0.0.1u24.aarch64pigsty12.9 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~noble_arm64.deb
postgresql-18-pg-redis-pubsub0.0.1u26.x86_64pigsty12.9 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~resolute_amd64.deb
postgresql-18-pg-redis-pubsub0.0.1u26.aarch64pigsty13.0 KiBpostgresql-18-pg-redis-pubsub_0.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_redis_pubsub_170.0.1el8.x86_64pigsty20.1 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el8.x86_64.rpm
pg_redis_pubsub_170.0.1el8.aarch64pigsty20.1 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el8.aarch64.rpm
pg_redis_pubsub_170.0.1el9.x86_64pigsty20.3 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el9.x86_64.rpm
pg_redis_pubsub_170.0.1el9.aarch64pigsty20.2 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el9.aarch64.rpm
pg_redis_pubsub_170.0.1el10.x86_64pigsty20.4 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el10.x86_64.rpm
pg_redis_pubsub_170.0.1el10.aarch64pigsty20.6 KiBpg_redis_pubsub_17-0.0.1-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-redis-pubsub0.0.1d12.x86_64pigsty12.3 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-redis-pubsub0.0.1d12.aarch64pigsty12.4 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-redis-pubsub0.0.1d13.x86_64pigsty12.3 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~trixie_amd64.deb
postgresql-17-pg-redis-pubsub0.0.1d13.aarch64pigsty12.4 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~trixie_arm64.deb
postgresql-17-pg-redis-pubsub0.0.1u22.x86_64pigsty13.2 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~jammy_amd64.deb
postgresql-17-pg-redis-pubsub0.0.1u22.aarch64pigsty13.0 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~jammy_arm64.deb
postgresql-17-pg-redis-pubsub0.0.1u24.x86_64pigsty12.9 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~noble_amd64.deb
postgresql-17-pg-redis-pubsub0.0.1u24.aarch64pigsty12.8 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~noble_arm64.deb
postgresql-17-pg-redis-pubsub0.0.1u26.x86_64pigsty12.9 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~resolute_amd64.deb
postgresql-17-pg-redis-pubsub0.0.1u26.aarch64pigsty13.0 KiBpostgresql-17-pg-redis-pubsub_0.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_redis_pubsub_160.0.1el8.x86_64pigsty20.1 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el8.x86_64.rpm
pg_redis_pubsub_160.0.1el8.aarch64pigsty20.1 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el8.aarch64.rpm
pg_redis_pubsub_160.0.1el9.x86_64pigsty20.3 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el9.x86_64.rpm
pg_redis_pubsub_160.0.1el9.aarch64pigsty20.1 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el9.aarch64.rpm
pg_redis_pubsub_160.0.1el10.x86_64pigsty20.4 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el10.x86_64.rpm
pg_redis_pubsub_160.0.1el10.aarch64pigsty20.5 KiBpg_redis_pubsub_16-0.0.1-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-redis-pubsub0.0.1d12.x86_64pigsty12.3 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-redis-pubsub0.0.1d12.aarch64pigsty12.4 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-redis-pubsub0.0.1d13.x86_64pigsty12.3 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~trixie_amd64.deb
postgresql-16-pg-redis-pubsub0.0.1d13.aarch64pigsty12.4 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~trixie_arm64.deb
postgresql-16-pg-redis-pubsub0.0.1u22.x86_64pigsty13.2 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~jammy_amd64.deb
postgresql-16-pg-redis-pubsub0.0.1u22.aarch64pigsty13.1 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~jammy_arm64.deb
postgresql-16-pg-redis-pubsub0.0.1u24.x86_64pigsty12.9 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~noble_amd64.deb
postgresql-16-pg-redis-pubsub0.0.1u24.aarch64pigsty12.8 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~noble_arm64.deb
postgresql-16-pg-redis-pubsub0.0.1u26.x86_64pigsty12.9 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~resolute_amd64.deb
postgresql-16-pg-redis-pubsub0.0.1u26.aarch64pigsty13.0 KiBpostgresql-16-pg-redis-pubsub_0.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_redis_pubsub_150.0.1el8.x86_64pigsty20.2 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el8.x86_64.rpm
pg_redis_pubsub_150.0.1el8.aarch64pigsty20.2 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el8.aarch64.rpm
pg_redis_pubsub_150.0.1el9.x86_64pigsty20.4 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el9.x86_64.rpm
pg_redis_pubsub_150.0.1el9.aarch64pigsty20.3 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el9.aarch64.rpm
pg_redis_pubsub_150.0.1el10.x86_64pigsty20.5 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el10.x86_64.rpm
pg_redis_pubsub_150.0.1el10.aarch64pigsty20.6 KiBpg_redis_pubsub_15-0.0.1-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-redis-pubsub0.0.1d12.x86_64pigsty12.4 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-redis-pubsub0.0.1d12.aarch64pigsty12.4 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-redis-pubsub0.0.1d13.x86_64pigsty12.4 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~trixie_amd64.deb
postgresql-15-pg-redis-pubsub0.0.1d13.aarch64pigsty12.5 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~trixie_arm64.deb
postgresql-15-pg-redis-pubsub0.0.1u22.x86_64pigsty13.2 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~jammy_amd64.deb
postgresql-15-pg-redis-pubsub0.0.1u22.aarch64pigsty13.1 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~jammy_arm64.deb
postgresql-15-pg-redis-pubsub0.0.1u24.x86_64pigsty13.0 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~noble_amd64.deb
postgresql-15-pg-redis-pubsub0.0.1u24.aarch64pigsty12.9 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~noble_arm64.deb
postgresql-15-pg-redis-pubsub0.0.1u26.x86_64pigsty13.0 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~resolute_amd64.deb
postgresql-15-pg-redis-pubsub0.0.1u26.aarch64pigsty13.1 KiBpostgresql-15-pg-redis-pubsub_0.0.1-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_redis_pubsub;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_redis_pubsub;		# install by package name
pig install redis;		# install by extension name

pig install redis -v 19;   # install for PG 19
pig install redis -v 18;   # install for PG 18
pig install redis -v 17;   # install for PG 17
pig install redis -v 16;   # install for PG 16
pig install redis -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION redis;

Usage

redis: Send Redis pub/sub messages to Redis from PostgreSQL directly

The redis extension (pg_redis_pubsub) allows PostgreSQL to publish messages to Redis pub/sub channels. Currently, only the publish side is supported.

Configuration

Set the Redis connection parameters via GUC variables:

ALTER SYSTEM SET redis.host = '127.0.0.1';
ALTER SYSTEM SET redis.port = '6379';
SELECT pg_reload_conf();

These can also be set at the database, role, or session level:

SET redis.host = '127.0.0.1';
SET redis.port = '6379';

Basic Usage

CREATE EXTENSION redis;

SELECT redis_connect();
SELECT redis_publish('mychannel', 'Hello World');
SELECT redis_disconnect();

Available Functions

FunctionDescription
redis_connect()Connect to Redis using redis.host and redis.port settings
redis_disconnect()Disconnect from Redis
redis_publish(channel text, message text)Publish a message on the specified channel
redis_status()Return the status of the Redis client

Note: redis_publish automatically connects if no connection exists.

Trigger Example

Publish change events to Redis whenever a table is modified:

CREATE OR REPLACE FUNCTION notify_changes()
RETURNS TRIGGER AS $$
BEGIN
  PERFORM redis_publish(
    'products:' || NEW.id::text,
    to_jsonb(NEW)::text
  );
  RETURN NULL;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER on_product_change
  AFTER INSERT OR UPDATE ON products
  FOR EACH ROW EXECUTE PROCEDURE notify_changes();

This allows external subscribers listening on Redis channels to react to PostgreSQL data changes in real time.

Table reader