Redis Lettuce backend
Latest stable Based on Leader release 0.4.0
Library module
Problem
Section titled “Problem”Implements single, fixed-slot group, and strategic election with Lettuce connections, token-owned Redis keys, Lua compare-and-delete/extend, and blocking/coroutine APIs.
When to use it
Section titled “When to use it”Choose it when Redis is already operated and the application prefers Lettuce’s connection model and explicit scripting.
Coordinates
Section titled “Coordinates”Artifact: io.github.bluetape4k.leader:bluetape4k-leader-redis-lettuce
dependencies { implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>")) implementation("io.github.bluetape4k.leader:bluetape4k-leader-redis-lettuce")}Core concepts
Section titled “Core concepts”A unique token owns a TTL key. Lua scripts make release and extension conditional. Strategic election stores candidate metadata and applies Core strategies.
Quick start
Section titled “Quick start”val elector = LettuceLeaderElector(connection)elector.runIfLeader("daily-report") { generateReport() }API by task
Section titled “API by task”Use the connection extension/factory, blocking/suspend single/group electors, and strategic electors. The connection is caller-owned.
Recommended patterns
Section titled “Recommended patterns”Use a dedicated key prefix, keep Redis client and connection lifecycle explicit, make actions idempotent, and plan behavior during failover.
Integrations
Section titled “Integrations”Spring can build factories from Lettuce resources. strategic-election and rate-limiter show candidate and group patterns.
Configuration
Section titled “Configuration”Configure wait/lease/minimum lease, auto-extension, key prefix, group size, retry, client timeouts, topology refresh, and Redis durability policy.
Failure modes
Section titled “Failure modes”Contention returns null. Timeout, MOVED/topology, script, authentication, and extension failures propagate. Expired ownership can overlap an old paused action.
Operations
Section titled “Operations”Monitor command latency, reconnects, topology changes, script failures, keyspace/TTL, extension failure, skip rate, and Redis memory pressure.
Testing
Section titled “Testing”Use Redis integration tests for two connections, token-safe release, expiry, group slots, strategic registry, failover handling, and suspend cancellation.
Workshops and learning path
Section titled “Workshops and learning path”Run strategic-election for candidate scoring and rate-limiter for group slots; compare Lettuce with Redisson’s higher-level client model.
Limitations
Section titled “Limitations”Redis availability and failover semantics are on the job path. A Redis token is not fencing for an external database.
Release diagrams
Section titled “Release diagrams”These diagrams are loaded directly from README assets published with the 0.4.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.
Lettuce Redis leader contract map
Section titled “Lettuce Redis leader contract map”Release README: leader-redis-lettuce/README.md
Lettuce slot-token acquire release and crash recovery flow
Section titled “Lettuce slot-token acquire release and crash recovery flow”Release README: leader-redis-lettuce/README.md
Lettuce minLeaseTime backend TTL delegation flow
Section titled “Lettuce minLeaseTime backend TTL delegation flow”Release README: leader-redis-lettuce/README.md


