docs/en/sql-reference/table-functions/redis.md
This table function allows integrating ClickHouse with Redis.
redis(host:port, key, structure[, db_index[, password[, pool_size]]])
| Argument | Description |
|---|---|
host:port | Redis server address, you can ignore port and default Redis port 6379 will be used. |
key | any column name in the column list. |
structure | The schema for the ClickHouse table returned from this function. |
db_index | Redis db index range from 0 to 15, default is 0. |
password | User password, default is blank string. |
pool_size | Redis max connection pool size, default is 16. |
primary | must be specified, it supports only one column in the primary key. The primary key will be serialized in binary as a Redis key. |
Named collections are not supported for redis table function at the moment.
A table object with key as Redis key, other columns packaged together as Redis value.
Read from Redis:
SELECT * FROM redis(
'redis1:6379',
'key',
'key String, v1 String, v2 UInt32'
)
Insert into Redis:
INSERT INTO TABLE FUNCTION redis(
'redis1:6379',
'key',
'key String, v1 String, v2 UInt32') values ('1', '1', 1);