redis

redis

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

Overview

ID Extension Package Version Category License Language
8720
redis
pg_redis_pubsub
0.0.1
FDW
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
redis_fdw
spat
pgmemcache
pg_net
wrappers
kafka_fdw
pgmq
multicorn

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
0.0.1
18
17
16
15
14
pg_redis_pubsub -
RPM
PIGSTY
0.0.1
18
17
16
15
14
pg_redis_pubsub_$v -
DEB
PIGSTY
0.0.1
18
17
16
15
14
postgresql-$v-pg-redis-pubsub -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
el8.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
el9.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
el9.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
el10.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
el10.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
d12.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
d12.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
d13.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
d13.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u22.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u22.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u24.x86_64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u24.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
Package Version OS ORG SIZE File URL
pg_redis_pubsub_18 0.0.1 el8.x86_64 pigsty 13.7 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el8.x86_64.rpm
pg_redis_pubsub_18 0.0.1 el8.aarch64 pigsty 14.0 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el8.aarch64.rpm
pg_redis_pubsub_18 0.0.1 el9.x86_64 pigsty 13.7 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el9.x86_64.rpm
pg_redis_pubsub_18 0.0.1 el9.aarch64 pigsty 13.7 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el9.aarch64.rpm
pg_redis_pubsub_18 0.0.1 el10.x86_64 pigsty 13.8 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el10.x86_64.rpm
pg_redis_pubsub_18 0.0.1 el10.aarch64 pigsty 13.9 KiB pg_redis_pubsub_18-0.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-redis-pubsub 0.0.1 d12.x86_64 pigsty 12.3 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-redis-pubsub 0.0.1 d12.aarch64 pigsty 12.3 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-redis-pubsub 0.0.1 d13.x86_64 pigsty 12.2 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-redis-pubsub 0.0.1 d13.aarch64 pigsty 12.3 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-redis-pubsub 0.0.1 u22.x86_64 pigsty 12.6 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-redis-pubsub 0.0.1 u22.aarch64 pigsty 12.5 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-redis-pubsub 0.0.1 u24.x86_64 pigsty 12.8 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~noble_amd64.deb
postgresql-18-pg-redis-pubsub 0.0.1 u24.aarch64 pigsty 12.8 KiB postgresql-18-pg-redis-pubsub_0.0.1-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_redis_pubsub_17 0.0.1 el8.x86_64 pigsty 13.7 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el8.x86_64.rpm
pg_redis_pubsub_17 0.0.1 el8.aarch64 pigsty 14.0 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el8.aarch64.rpm
pg_redis_pubsub_17 0.0.1 el9.x86_64 pigsty 13.7 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el9.x86_64.rpm
pg_redis_pubsub_17 0.0.1 el9.aarch64 pigsty 13.7 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el9.aarch64.rpm
pg_redis_pubsub_17 0.0.1 el10.x86_64 pigsty 13.8 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el10.x86_64.rpm
pg_redis_pubsub_17 0.0.1 el10.aarch64 pigsty 13.9 KiB pg_redis_pubsub_17-0.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-redis-pubsub 0.0.1 d12.x86_64 pigsty 12.2 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-redis-pubsub 0.0.1 d12.aarch64 pigsty 12.3 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-redis-pubsub 0.0.1 d13.x86_64 pigsty 12.2 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-redis-pubsub 0.0.1 d13.aarch64 pigsty 12.3 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-redis-pubsub 0.0.1 u22.x86_64 pigsty 13.1 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-redis-pubsub 0.0.1 u22.aarch64 pigsty 13.0 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-redis-pubsub 0.0.1 u24.x86_64 pigsty 12.8 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~noble_amd64.deb
postgresql-17-pg-redis-pubsub 0.0.1 u24.aarch64 pigsty 12.7 KiB postgresql-17-pg-redis-pubsub_0.0.1-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_redis_pubsub_16 0.0.1 el8.x86_64 pigsty 13.7 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el8.x86_64.rpm
pg_redis_pubsub_16 0.0.1 el8.aarch64 pigsty 14.0 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el8.aarch64.rpm
pg_redis_pubsub_16 0.0.1 el9.x86_64 pigsty 13.7 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el9.x86_64.rpm
pg_redis_pubsub_16 0.0.1 el9.aarch64 pigsty 13.7 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el9.aarch64.rpm
pg_redis_pubsub_16 0.0.1 el10.x86_64 pigsty 13.8 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el10.x86_64.rpm
pg_redis_pubsub_16 0.0.1 el10.aarch64 pigsty 13.9 KiB pg_redis_pubsub_16-0.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-redis-pubsub 0.0.1 d12.x86_64 pigsty 12.2 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-redis-pubsub 0.0.1 d12.aarch64 pigsty 12.3 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-redis-pubsub 0.0.1 d13.x86_64 pigsty 12.2 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-redis-pubsub 0.0.1 d13.aarch64 pigsty 12.3 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-redis-pubsub 0.0.1 u22.x86_64 pigsty 13.1 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-redis-pubsub 0.0.1 u22.aarch64 pigsty 13.0 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-redis-pubsub 0.0.1 u24.x86_64 pigsty 12.8 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~noble_amd64.deb
postgresql-16-pg-redis-pubsub 0.0.1 u24.aarch64 pigsty 12.7 KiB postgresql-16-pg-redis-pubsub_0.0.1-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_redis_pubsub_15 0.0.1 el8.x86_64 pigsty 13.8 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el8.x86_64.rpm
pg_redis_pubsub_15 0.0.1 el8.aarch64 pigsty 14.1 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el8.aarch64.rpm
pg_redis_pubsub_15 0.0.1 el9.x86_64 pigsty 13.8 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el9.x86_64.rpm
pg_redis_pubsub_15 0.0.1 el9.aarch64 pigsty 13.8 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el9.aarch64.rpm
pg_redis_pubsub_15 0.0.1 el10.x86_64 pigsty 13.9 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el10.x86_64.rpm
pg_redis_pubsub_15 0.0.1 el10.aarch64 pigsty 14.0 KiB pg_redis_pubsub_15-0.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-redis-pubsub 0.0.1 d12.x86_64 pigsty 12.3 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-redis-pubsub 0.0.1 d12.aarch64 pigsty 12.4 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-redis-pubsub 0.0.1 d13.x86_64 pigsty 12.3 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-redis-pubsub 0.0.1 d13.aarch64 pigsty 12.4 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-redis-pubsub 0.0.1 u22.x86_64 pigsty 13.1 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-redis-pubsub 0.0.1 u22.aarch64 pigsty 13.0 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-redis-pubsub 0.0.1 u24.x86_64 pigsty 12.9 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~noble_amd64.deb
postgresql-15-pg-redis-pubsub 0.0.1 u24.aarch64 pigsty 12.8 KiB postgresql-15-pg-redis-pubsub_0.0.1-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_redis_pubsub_14 0.0.1 el8.x86_64 pigsty 13.8 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el8.x86_64.rpm
pg_redis_pubsub_14 0.0.1 el8.aarch64 pigsty 14.1 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el8.aarch64.rpm
pg_redis_pubsub_14 0.0.1 el9.x86_64 pigsty 13.8 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el9.x86_64.rpm
pg_redis_pubsub_14 0.0.1 el9.aarch64 pigsty 13.8 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el9.aarch64.rpm
pg_redis_pubsub_14 0.0.1 el10.x86_64 pigsty 13.9 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el10.x86_64.rpm
pg_redis_pubsub_14 0.0.1 el10.aarch64 pigsty 14.0 KiB pg_redis_pubsub_14-0.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-redis-pubsub 0.0.1 d12.x86_64 pigsty 12.3 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-redis-pubsub 0.0.1 d12.aarch64 pigsty 12.3 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-redis-pubsub 0.0.1 d13.x86_64 pigsty 12.3 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-redis-pubsub 0.0.1 d13.aarch64 pigsty 12.4 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-redis-pubsub 0.0.1 u22.x86_64 pigsty 13.1 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-redis-pubsub 0.0.1 u22.aarch64 pigsty 13.0 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-redis-pubsub 0.0.1 u24.x86_64 pigsty 12.9 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~noble_amd64.deb
postgresql-14-pg-redis-pubsub 0.0.1 u24.aarch64 pigsty 12.8 KiB postgresql-14-pg-redis-pubsub_0.0.1-1PIGSTY~noble_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 via package name, for the active PG version
pig install redis;		# install by extension name, for the current active PG version

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
pig install redis -v 14;   # install for PG 14

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

Function Description
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.

Last updated on