Back
Redis Wrapper

Redis Wrapper

Overview

Redis Wrapper

Redis is an open-source in-memory data store used as a distributed cache, key-value database, and message broker. It supports rich data structures including strings, hashes, lists, sets, sorted sets, and streams, with optional durability and sub-millisecond latency at scale.

The Redis Wrapper brings your Redis data into Postgres as queryable foreign tables. Query lists, sets, hashes, sorted sets, and streams with plain SQL and join them against your application data. Read-only, and works with Supabase Vault for secure connection URL management.

Supported Data Types

Redis TypePostgres Type
listtext, jsonb
settext, jsonb
hashtext, jsonb
zsettext, jsonb
streamtext, jsonb

Preparation

Before you get started, make sure the wrappers extension is installed on your database:


_10
create extension if not exists wrappers with schema extensions;

and then create the foreign data wrapper:


_10
create foreign data wrapper redis_wrapper
_10
handler redis_fdw_handler
_10
validator redis_fdw_validator;

Secure your credentials (optional)

By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.


_10
select vault.create_secret(
_10
'redis://username:password@127.0.0.1:6379/db',
_10
'redis',
_10
'Redis connection URL for Wrappers'
_10
);

To connect over SSL/TLS, use the rediss:// protocol:


_10
rediss://username:password@my-redis-12345.upstash.io:6379/#insecure

Connecting to Redis

We need to provide Postgres with the credentials to connect to Redis. We can do this using the create server command:

With Vault:


_10
create server redis_server
_10
foreign data wrapper redis_wrapper
_10
options (
_10
conn_url_id '<key_ID>' -- The Key ID from above.
_10
);

Without Vault:


_10
create server redis_server
_10
foreign data wrapper redis_wrapper
_10
options (
_10
conn_url 'redis://username:password@127.0.0.1:6379/db'
_10
);

Resources

Details

DeveloperSupabase
DocumentationLearn

Third-party integrations and docs are managed by Supabase partners.

Get started with Redis Wrapper and Supabase.