Redis compatible Client for DuckDB
Maintainer(s):
lmangani
Installing and Loading
INSTALL redis FROM community;
LOAD redis;
Example
-- Create a local Redis connection secret
CREATE SECRET IF NOT EXISTS redis (
TYPE redis,
PROVIDER config,
host 'localhost',
port '6379',
password 'optional_password'
);
-- Create a Redis cloud connection secret
CREATE SECRET IF NOT EXISTS redis (
TYPE redis,
PROVIDER config,
host 'redis-1234.ec2.redns.redis-cloud.com',
port '16959',
password 'xxxxxx'
);
-- Set a value
SELECT redis_set('user:1', 'John Doe', 'redis') as result;
-- Get a value
SELECT redis_get('user:1', 'redis') as user_name;
-- Set hash fields
SELECT redis_hset('user:1', 'email', '[email protected]', 'redis');
SELECT redis_hset('user:1', 'age', '30', 'redis');
-- Get hash field
SELECT redis_hget('user:1', 'email', 'redis') as email;
-- Push items to list
SELECT redis_lpush('mylist', 'first_item', 'redis');
SELECT redis_lpush('mylist', 'second_item', 'redis');
-- Get range from list (returns comma-separated values)
-- Get all items (0 to -1 means start to end)
SELECT redis_lrange('mylist', 0, -1, 'redis') as items;
-- Get first 5 items
SELECT redis_lrange('mylist', 0, 4, 'redis') as items;
-- Push multiple items
WITH items(value) AS (
VALUES ('item1'), ('item2'), ('item3')
)
SELECT redis_lpush('mylist', value, 'redis')
FROM items;
About redis
DuckDB Redis Client Extension
This extension provides Redis-compatible client functionality for DuckDB
Experimental: USE AT YOUR OWN RISK!
Features
Currently supported Redis operations:
- String operations:
GET
,SET
- Hash operations:
HGET
,HSET
- List operations:
LPUSH
,LRANGE
- Batch operations:
MGET
,SCAN
Added Functions
function_name | function_type | description | comment | examples |
---|---|---|---|---|
redis_get | scalar | NULL | NULL | [] |
redis_hget | scalar | NULL | NULL | [] |
redis_hset | scalar | NULL | NULL | [] |
redis_lpush | scalar | NULL | NULL | [] |
redis_lrange | scalar | NULL | NULL | [] |
redis_mget | scalar | NULL | NULL | [] |
redis_scan | scalar | NULL | NULL | [] |
redis_set | scalar | NULL | NULL | [] |