Expand description
Production Remote adapter over the [redis] crate.
RedisAdapter borrows a connected, caller-owned connection handle: a
[ConnectionManager] for standalone or Sentinel-managed servers, a
[ClusterConnection] for Redis Cluster, or a plain
[MultiplexedConnection]. It never connects, reconnects, drains or closes
the handle and never changes its options. The caller remains responsible
for:
- Finite budgets. Configure connection, response and retry limits on
the handle (
ConnectionManagerConfig::set_response_timeout,ClusterClientBuilder::response_timeout, …). The cache bounds its own wait for reads and honors cooperative cancellation, but cancellation after dispatch cannot prove a command did not execute. - Primaries for tracked reads. On a cluster handle the adapter routes
every tracked
MGETexplicitly to the slot primary, so replica lag can never hide an invalidation watermark even when the caller enabledread_from_replicas. A standalone or Sentinel-managed handle must point at the primary itself; the adapter cannot tell a replica apart. - Watermark retention. Invalidation stores watermarks with a retention of at least two hours that only widens. Configure eviction so watermark keys are not evicted before tracked values age out; an evicted watermark resurrects fenced values.
Wire behavior matches the TypeScript and Go adapters exactly: an
untracked read is one GET; a tracked read is one MGET value watermark
on the primary; a write is exactly one native SET key frame PX ttl; an
invalidation is EVALSHA of INVALIDATION_SCRIPT with one EVAL
retry carrying identical arguments after any EVALSHA failure. Accepted
but invalid replies are RedisProtocolErrors and are never retried.
Structs§
- Redis
Adapter Remoteover a caller-ownedrediscrate connection handle.- Redis
Protocol Error - A reply the server accepted but that violates the DialCache wire protocol.
- Redis
Read Cancelled - A read stopped waiting because its
ReadContextwas cancelled.
Constants§
- INVALIDATION_
SCRIPT - The version-1 wire invalidation transition, byte-identical to the Go
InvalidationScript(a unit test pins this againstgo/redis_adapter.go). TypeScript’sINVALIDATE_CACHE_SCRIPTis the same Lua with different whitespace and a comment, so itsEVALSHAdigest differs; every port self-heals through theEVALfallback, so mixed-language clusters need no shared script cache.
Traits§
- Redis
Connection - A cloneable, task-shareable handle that runs one Redis command.
Functions§
- invalidation_
script_ sha1 - Lowercase hex SHA-1 of
INVALIDATION_SCRIPT, theEVALSHAargument. - validate_
invalidation_ reply - The invalidation script must answer the integer
1. - validate_
set_ reply SETmust answerOK.