Skip to main content

redis

9 configuration options · available in Rust, Java, Python, Node.js, Go

Quick start
use opendal::Operator;

let operator = Operator::via_iter("redis", [
("db".to_string(), "1000".to_string()),
])?;
All configuration options (copy & trim)
Full reference
use opendal::Operator;

let operator = Operator::via_iter("redis", [
// network address of the Redis service. Can be "tcp://127.0.0.1:6379", e.g.
//
// default is "tcp://127.0.0.1:6379"
// ("endpoint".to_string(), "...".to_string()),

// network address of the Redis cluster service. Can be "tcp://127.0.0.1:6379,tcp://127.0.0.1:6380,tcp://127.0.0.1:6381", e.g.
//
// default is None
// ("cluster_endpoints".to_string(), "...".to_string()),

// Route read-only commands for `read` and `stat` to Redis Cluster replicas when available.
//
// Defaults to `false`. Enabling this option requires `cluster_endpoints`.
// Replication lag can cause stale results. For example, `read` or `stat` can
// briefly return `ErrorKind::NotFound` for a just-written key. OpenDAL returns
// a replica miss without retrying on the primary.
// ("read_from_replicas".to_string(), "false".to_string()),

// The maximum number of connections allowed.
//
// default is 10
// ("connection_pool_max_size".to_string(), "1000".to_string()),

// the username to connect redis service.
//
// default is None
// ("username".to_string(), "...".to_string()),

// the password for authentication
//
// default is None
// ("password".to_string(), "...".to_string()),

// the working directory of the Redis service. Can be "/path/to/dir"
//
// default is "/"
// ("root".to_string(), "...".to_string()),

// the number of DBs redis can take is unlimited
//
// default is db 0
("db".to_string(), "1000".to_string()),

// The default ttl for put operations.
// ("default_ttl".to_string(), "10s".to_string()),
])?;

Every option is passed as a string key; OpenDAL parses it into the right type. Some services may require building the binding with the matching services-* feature enabled.

Configuration reference

General9
KeyTypeRequiredDescription
endpointstringnonetwork address of the Redis service. Can be "tcp://127.0.0.1:6379", e.g. default is "tcp://127.0.0.1:6379"
cluster_endpointsstringnonetwork address of the Redis cluster service. Can be "tcp://127.0.0.1:6379,tcp://127.0.0.1:6380,tcp://127.0.0.1:6381", e.g. default is None
read_from_replicasdefault falseboolnoRoute read-only commands for read and stat to Redis Cluster replicas when available. Defaults to false. Enabling this option requires cluster_endpoints. Replication lag can cause stale results. For example, read or stat can briefly return ErrorKind::NotFound for a just-written key. OpenDAL returns a replica miss without retrying on the primary.
connection_pool_max_sizeintegernoThe maximum number of connections allowed. default is 10
usernamestringnothe username to connect redis service. default is None
passwordstringnothe password for authentication default is None
rootstringnothe working directory of the Redis service. Can be "/path/to/dir" default is "/"
dbintegeryesthe number of DBs redis can take is unlimited default is db 0
default_ttldurationnoThe default ttl for put operations.