Redis
redis-rs's ConnectionManager as a store, built lazily so the module's ping is the one retry policy.
ulo-db-redis binds redis-rs's ConnectionManager. Redis has no migrator, so the module has no .migrate(..).
use ulo_db_redis::RedisModule;
m.import(RedisModule::from_config(&config, "redis"));Options
| Key | Default | Meaning |
|---|---|---|
url | required | redis:// or rediss://. A Secret. rediss:// needs the crate's tls feature. |
connection_timeout_secs | 5 | The bound on one connection attempt, which the retry loop repeats under connect_within. |
response_timeout_secs | redis-rs's 500 ms | The bound on one command once connected, the health ping included. |
Both timeouts are whole seconds and must not be zero.
Features
| Feature | Effect |
|---|---|
tls | rediss://, through rustls with the webpki roots. |
smol-comp | Compiles redis-rs's smol-comp beside tokio-comp and calls prefer_tokio() once per process. Off by default. |
Connecting
The manager is built with ConnectionManager::new_lazy_with_config, which connects nothing. The first command makes the connection. create therefore cannot fail on an unreachable server and .lazy() is offered. Under the default start the first ping is the first connection, retried under connect_within. A wrong password is permanent and ends the start at its first attempt.
redis-rs's own reconnect count is set to 0 so the module's ping is the one retry policy. A wrong password fails in 2 ms at 0, 1.2 s at 3 and 9.5 s at redis-rs's default of 6. A brief outage costs one failed command at every setting and recovery takes the same time, so the library's retries only lengthen the wait before a failure.
The runtime preference
The crate enables redis-rs's tokio-comp alone. When another crate in the build compiles in smol-comp, redis-rs chooses a runtime through a process-global preference. The choice is prefer_tokio() or prefer_smol() if some crate set one, otherwise tokio where a tokio context exists, which the app's runtime provides.
With the smol-comp feature on, the crate calls prefer_tokio() once per process. A refusal, because another crate set a preference first, is logged at warn and the start continues. With the feature off nothing is called, and a dependency that calls prefer_smol() is not detected: redis-rs then spawns onto smol's global executor, not the app's runtime.
ConnectionManager has no close, so the module's destroy hook drops the handle. No test exercises rediss://.