Redis Keyspace, TTLs, And Cleanup Targets
Redis stores short-lived coordination state for sessions, handoffs, presence, registry records, transfer activation markers, throttles, internal request nonces, and durable queue pointers. The redis-keyspace crate owns key names and cleanup descriptors so services do not invent incompatible keys.
Purpose
Use this page when debugging stale presence, consumed handoffs, transfer activation loops, failed-login throttles, or admin Redis cleanup.
Keyspace Owners
Login owns login sessions, failed-login throttles, and character-entry handoff preparation. Control plane owns service registry, handoff storage, transfer activation status, and admin cleanup. Game server owns realtime presence repair, transfer marker reconciliation, shared networking counters, and session lifecycle journal processing.
Shared key builders belong in crates/redis-keyspace. Add new keys there first.
TTL Table
Handoff records use the caller-provided TTL and are stored under scoped login:handoff:* keys. Consumed-handoff markers use login:handoff-consumed:* and a default consumed marker TTL. Transfer activation confirmations use transfer:activated:* and caller-provided TTL. Presence records use TTLs derived from their expires_at. Registry records use registration TTLs. Failed-login throttles use the configured login throttle window. Internal request nonces use the verifier skew window.
If a value should expire, prefer SETEX or the helper that already records TTL behavior.
Handoff Scopes And Consumed Markers
Handoffs can be scoped by instance, placement, or port for compatibility. Consumption checks the consumed marker first, then atomically takes the first matching handoff. The consumed marker prevents replay after the handoff payload disappears.
Do not manually delete only one scoped handoff key when redirecting or moving a handoff. Use the shared move/take helpers so TTL and scope ordering stay intact.
Registry And Presence Pruning
Registry reads prune stale instance set members when the instance payload key no longer exists. Presence reads prune stale account set members and can delete mismatched account or character records during game-server reconciliation.
This means a set member without a payload is a cleanup target, not proof that the player or instance is still alive.
Transfer Activation Markers
Transfer activation markers prove that a target game server activated a transfer token. Game-server reconciliation scans transfer:activated:* and removes stale observed keys that no longer correspond to live pending transfer tokens.
Internal Nonce Replay Keys
Signed internal requests register nonce keys under the control-plane nonce scope. A repeated nonce inside the skew window should be rejected before the route handler mutates Redis or the database.
Admin Cleanup Targets
Admin cleanup descriptors expose presence, handoff, and registry targets with names, owners, exact keys, or scan patterns. Dry run uses count-only mode. Delete mode scans and deletes bounded batches; it must not plan a raw KEYS command.
Operational Do And Don't
Use descriptor-owned cleanup for stale groups. Avoid deleting unknown patterns manually. Preserve TTLs when moving coordination records. When debugging replay or stale state, identify whether the key is an owner payload, an index member, a consumed marker, or a nonce.