Keys functions in the Redis DuckDB extension
Function category
Keys
6 functionsDEL / EXISTS / TYPE / SCAN — keyspace introspection and management. Key listing is built on cursor-paginated SCAN, never the server-blocking KEYS command.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
key
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Delete a key. Returns TRUE if the key existed and was removed.
SELECT redis_del('mykey', 'my_redis_secret');
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
key
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Check whether a key exists.
SELECT redis_exists('mykey', 'my_redis_secret');
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
pattern
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
List all keys matching a pattern as a table, one row per key. Built on SCAN, not KEYS: it follows the cursor page by page until the keyspace is exhausted, so it doesn't block the server — but it always walks the whole keyspace. Use redis_scan to page manually.
SELECT * FROM redis_keys('*', 'my_redis_secret');
SELECT * FROM redis_keys('user:*', 'my_redis_secret');
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cursor
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
pattern
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
count
|
Type
BIGINT
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Cursor-paginated SCAN of the keyspace, one page per call. Returns 'next_cursor:keys_csv'. Iterate by re-passing the returned cursor until it comes back as '0'. Prefer redis_scan_page for a typed result.
SELECT redis_scan('0', '*', 100, 'my_redis_secret');
SELECT redis_scan('0', 'user:*', 10, 'my_redis_secret');
Related functions
- redis_scan_page() — One SCAN step over the keys matching a pattern, typed: returns STRUCT(cursor VARCHAR, keys VARCHAR[])
- redis_keys() — List all keys matching a pattern as a table, one row per key
- redis_hscan_over_scan() — For every key matching a SCAN pattern, run HSCAN and emit (key, field, value) rows, following both cursors to the end
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
cursor
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
pattern
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
count
|
Type
BIGINT
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
One SCAN step over the keys matching a pattern, typed: returns STRUCT(cursor VARCHAR, keys VARCHAR[]). Re-pass the cursor until it comes back as '0'; a key may appear in more than one page. DuckDB 2.0 build.
SELECT redis_scan_page('0', 'user:*', 100, 'my_redis_secret');
SELECT unnest(redis_scan_page('0', '*', 1000, 'my_redis_secret').keys) AS key;
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
key
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
secret_name
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Get the Redis type of a key (string / list / hash / set / zset / stream / none).
SELECT redis_type('mykey', 'my_redis_secret');