feat: add memory-authoritative write-behind mode for Redis - #1
Merged
Conversation
Adds an optional "memory-authoritative" mode where Redis is used purely as an async write-behind layer, keeping the hot path fully in-memory after warmup. All changes are backward-compatible (defaults preserve existing read-through behavior). - Single round-trip Redis reads via optional RedisGetTTLClient interface (implemented by v8/v9 adapters with a GET+TTL pipeline); falls back to separate Get+TTL otherwise. - WithWriteThroughOnly(): disables synchronous Redis reads on local miss for Get/getFallback/ModifyNumeric/SetNX; writes still flow async. - WarmFromRedis(keys): loads state from Redis into memory at startup for durability across restarts without runtime synchronous reads. - Local-authoritative SetNX in write-through-only mode: atomicity via the local shard lock, async SETNX to Redis; default behavior preserved. - Fix silent drop-on-full: centralize async sends through enqueueRedis, count drops via DroppedWrites(), and add WithBlockOnFull(d) to block briefly instead of dropping. - Tests for all new behavior (miniredis-backed, no external Redis needed). - README updated with new features and clarified read-through semantics. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional "memory-authoritative" mode where Redis is used purely as an async write-behind layer, keeping the hot path fully in-memory after warmup. All changes are backward-compatible (defaults preserve existing read-through behavior).