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 Type | Postgres Type |
|---|---|
| list | text, jsonb |
| set | text, jsonb |
| hash | text, jsonb |
| zset | text, jsonb |
| stream | text, jsonb |
Preparation
Before you get started, make sure the wrappers extension is installed on your database:
_10create extension if not exists wrappers with schema extensions;
and then create the foreign data wrapper:
_10create 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.
_10select 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:
_10rediss://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:
_10create 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:
_10create 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
Third-party integrations and docs are managed by Supabase partners.