redis_fdw
Foreign data wrapper for querying a Redis server
Repository
pg-redis-fdw/redis_fdw
https://github.com/pg-redis-fdw/redis_fdw
Source
redis_fdw-1.0.tar.gz
redis_fdw-1.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
redis_fdw | 1.0 | FDW | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 8710 | redis_fdw | No | Yes | No | Yes | No | Yes | - |
| Related | mongo_fdw redis kafka_fdw wrappers multicorn spat pgmemcache odbc_fdw |
|---|
multiple branch for different pg major versions
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | redis_fdw | - |
| RPM | PIGSTY | 1.0 | 1817161514 | redis_fdw_$v | - |
| DEB | PIGSTY | 1.0 | 1817161514 | postgresql-$v-redis-fdw | - |
Build
You can build the RPM / DEB packages for redis_fdw using pig build:
pig build pkg redis_fdw # build RPM / DEB packages
Install
You can install redis_fdw directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install redis_fdw; # Install for current active PG version
pig ext install -y redis_fdw -v 18 # PG 18
pig ext install -y redis_fdw -v 17 # PG 17
pig ext install -y redis_fdw -v 16 # PG 16
pig ext install -y redis_fdw -v 15 # PG 15
pig ext install -y redis_fdw -v 14 # PG 14
dnf install -y redis_fdw_18 # PG 18
dnf install -y redis_fdw_17 # PG 17
dnf install -y redis_fdw_16 # PG 16
dnf install -y redis_fdw_15 # PG 15
dnf install -y redis_fdw_14 # PG 14
apt install -y postgresql-18-redis-fdw # PG 18
apt install -y postgresql-17-redis-fdw # PG 17
apt install -y postgresql-16-redis-fdw # PG 16
apt install -y postgresql-15-redis-fdw # PG 15
apt install -y postgresql-14-redis-fdw # PG 14
Create Extension:
CREATE EXTENSION redis_fdw;
Usage
Create Server
CREATE EXTENSION redis_fdw;
CREATE SERVER redis_server FOREIGN DATA WRAPPER redis_fdw
OPTIONS (address '127.0.0.1', port '6379');
Server Options: address (default 127.0.0.1), port (default 6379).
Create User Mapping
CREATE USER MAPPING FOR pguser SERVER redis_server
OPTIONS (password 'secret');
Scalar Key-Value Pairs
CREATE FOREIGN TABLE redis_db0 (
key text,
val text
)
SERVER redis_server
OPTIONS (database '0');
SELECT * FROM redis_db0;
Hash Tables (with Key Prefix)
CREATE FOREIGN TABLE redis_hash (
key text,
val text[]
)
SERVER redis_server
OPTIONS (database '0', tabletype 'hash', tablekeyprefix 'mytable:');
INSERT INTO redis_hash VALUES ('mytable:r1', '{prop1,val1,prop2,val2}');
UPDATE redis_hash SET val = '{prop3,val3}' WHERE key = 'mytable:r1';
DELETE FROM redis_hash WHERE key = 'mytable:r1';
SELECT * FROM redis_hash;
Hash Tables (Singleton Key)
CREATE FOREIGN TABLE redis_singleton (
key text,
val text
)
SERVER redis_server
OPTIONS (database '0', tabletype 'hash', singleton_key 'myhash');
INSERT INTO redis_singleton VALUES ('field1', 'value1');
UPDATE redis_singleton SET val = 'newvalue' WHERE key = 'field1';
DELETE FROM redis_singleton WHERE key = 'field1';
Table Options
| Option | Description |
|---|---|
database | Redis database number (default 0) |
tabletype | hash, list, set, or zset (omit for scalar key-value) |
tablekeyprefix | Filter items by key prefix |
tablekeyset | Fetch keys from a specific Redis set |
singleton_key | Access all values from a single Redis key |
Use only one of tablekeyset or tablekeyprefix. Do not combine them with singleton_key.
Hash values are returned as alternating key-value pairs in a text[] array. Lists, sets, and sorted sets also return values as arrays.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.