redis-tower
A typed, async Redis client built around Tower services.
- Typed commands and responses for Redis 7.x, Redis 8.x, and Redis Stack.
- A cloneable, auto-pipelined client for normal application traffic.
- Standalone, Cluster, Sentinel, blocking, and topology-neutral clients.
- Tower middleware, reconnection, pooling, client-side caching, metrics, TLS, and rotating credentials.
Install
The default feature set includes the Redis Stack command builders. A smaller core-only dependency looks like this:
[]
= { = "0.1", = false }
= { = "1", = ["macros", "rt-multi-thread"] }
Add the topology or higher-level crates only when you need them:
The minimum supported Rust version is 1.88.
Quick start
MultiplexedClient
is the recommended default. It is cheap to clone, accepts concurrent commands,
and automatically pipelines work over one connection.
use ;
use ;
# async
Redis URLs support authentication, database selection, Unix sockets, and TLS:
# async
Unix URLs use the redis-rs-compatible query form. Socket paths are
percent-decoded, and the redis+unix and valkey+unix aliases are accepted:
# async
Choose a client
| Client | Use it for |
|---|---|
MultiplexedClient |
Most async applications; cloneable and auto-pipelined |
CachedMultiplexedClient |
Read-heavy standalone workloads using RESP3 client-side caching |
RedisConnection |
Exclusive access to one connection or custom Tower stacks |
RedisClient |
Simple serialized sharing behind a mutex |
ResilientRedisClient |
Automatic reconnect with optional bounded offline queuing |
ConnectionPool |
Blocking commands, multiple sockets, or CPU-heavy response parsing |
MultiplexedClusterClient |
High-concurrency Redis Cluster workloads |
MultiplexedSentinelClient |
Sentinel discovery, failover, and replica reads |
UniversalClient |
One application type selected by standalone, Cluster, or Sentinel URL |
SyncClient |
CLI tools and other blocking code |
The production tuning guide goes deeper on client selection, backpressure, timeouts, pooling, reconnects, and shutdown.
Common operations
Commands are ordinary typed values. Optional arguments use builder methods.
use ;
let set = new.ex.nx;
let score = new.member;
let event = new.field;
# let _ = ;
Pipelines batch a known group of commands. Transactions use Redis
WATCH/MULTI/EXEC semantics.
# async
Deployment topologies
For binary channel or pattern names, use BinaryPubSubConnection and the
subscribe_bytes / psubscribe_bytes / ssubscribe_bytes methods. Messages
and tracked subscriptions retain Bytes, including across reconnects. Cluster
clients expose pubsub_on_bytes and sharded_pubsub_bytes with the same
routing and recovery behavior as the text API.
RESP3 attribute-prefixed replies currently fail with a protocol error. The transport closes rather than assign an attribute or its payload to the wrong pipelined request. Complete attribute metadata support needs a response model that pairs the prefix with its following value.
Cluster
# async
Raw FT.CURSOR and counted set/cardinality commands route by the index or
first declared key, including binary keys and hash tags.
For node-local or connection-stateful work, client.connect_to_node(node)
opens an exclusively owned connection to a current topology member using the
client's authentication, TLS, protocol, and connection timeout settings. The
caller bounds command duration and owns the socket; shared workers remain
available. This connection does not route commands or replay failures.
The Cluster crate also provides explicit cross-node pipelines, split multi-key helpers, cluster-wide scans, regular and sharded Pub/Sub, replica routing, and automatic MOVED/ASK handling.
Sentinel
# async
One client for every topology
redis-tower-client chooses a variant from the URL scheme:
# async
Use the rediss, rediss+cluster, and rediss+sentinel variants for TLS.
Data access modules
The redis-tower-modules crate provides higher-level clients over the lower-
level typed command builders.
| Module | Client | Typical use |
|---|---|---|
| RedisJSON | json::JsonClient |
Serialize application types with Serde |
| RediSearch | search::SearchClient |
Define indexes and deserialize query results |
| RedisTimeSeries | timeseries::TimeSeriesClient |
Store and query timestamped samples |
| Probabilistic | probabilistic::* |
Bloom, Cuckoo, CMS, TopK, and T-Digest |
| Vector Sets | vector::VectorSetClient |
Add vectors and run similarity search |
JSON
# async
Search, time series, probabilistic structures, and vectors
# async
Pub/Sub, streams, and caching
# async
For durable processing, use Redis Streams through the typed X* commands or
StreamConsumer.
RESP3 client-side caching is available as a managed client:
# async
Read the client-side caching guide for invalidation, failure, and consistency semantics.
Tower middleware
FrameService is a tower::Service<Frame>. CommandAdapter converts a frame
stack back into a typed command service.
# async
The facade also includes request deadlines, Redis-aware retries and circuit breaking, reconnection, cache middleware, and metrics-facade integration.
Distributed primitives
redis-tower-primitives builds coordination tools on the same typed executor:
- Fenced distributed locks and leader election.
- Expirable semaphores and countdown latches.
- Delayed queues and block-allocated IDs.
- Redis-time GCRA rate limiting.
# async
These are Redis-backed leases, not consensus primitives. Read the distributed primitives guide before using them for correctness-sensitive work.
Authentication, TLS, and blocking code
Static credentials can be supplied through URLs or builders. Dynamic
credentials implement CredentialProvider; companion crates provide AWS
ElastiCache IAM and Microsoft Entra ID integrations:
redis-tower-auth-awsredis-tower-auth-azure
The cloud authentication guide covers URL-backed provider factories, setup deadlines, shared provider caches, reconnect-time refresh, and the reconnect/replay rules for dedicated Pub/Sub, MONITOR, blocking, and transactional sessions.
Blocking applications can use redis-tower-sync:
use SyncClient;
use ;
#
Workspace crates
| Crate | Purpose |
|---|---|
redis-tower |
Main client facade, middleware, pooling, caching, and resilience |
redis-tower-core |
Connection, command trait, Tower frame service, URL/TLS, conversions |
redis-tower-protocol |
RESP3 frames and bounded Tokio codec |
redis-tower-commands |
Typed Redis and Redis Stack command builders |
redis-tower-cluster |
Cluster topology, routing, redirects, scans, pipelines, and Pub/Sub |
redis-tower-sentinel |
Sentinel discovery, failover, and replica reads |
redis-tower-client |
Topology-neutral UniversalClient |
redis-tower-modules |
High-level JSON, Search, TimeSeries, probabilistic, and vector clients |
redis-tower-primitives |
Distributed coordination primitives |
redis-tower-sync |
Blocking wrapper |
redis-tower-auth-aws |
ElastiCache IAM credentials |
redis-tower-auth-azure |
Microsoft Entra ID credentials |
redis-tower-test |
Mocks and managed Redis test fixtures |
Learn more
- Documentation home
- Command cookbook
- Command capability ledger
- Production tuning
- Serverless and scale-to-zero
- Client-side caching
- Cloud and rotating credentials
- Distributed primitives
- Migrating from redis-rs
- Migrating from Fred
- Sourced client comparison
- Test conformance
Runnable programs live in the
examples
directory.
Compatibility
Redis 7.x and 8.x are the supported server lines. CI exercises Redis 7.4 and 8.0 on every change, with a broader nightly Redis and Valkey matrix. Redis Stack command groups are feature-gated and return normal server errors when a module is unavailable.
redis-tower is pre-1.0. A 0.x minor release may contain breaking changes;
those changes are called out in crate changelogs.
Security
See SECURITY.md for the vulnerability disclosure policy. The workspace forbids unsafe code and runs dependency policy and advisory checks in CI.
Contributing
See CONTRIBUTING.md for development setup and validation commands.
License
Licensed under either the MIT License or the Apache License, Version 2.0, at your option.
The vendored Redis documentation metadata used by the repository's conformance reports is licensed separately. See its license and attribution notice; that metadata is not included in the released Rust crates.