feat: Add Redis Key-Value Backend With TTL and Sorted Sets - #6
Open
ThomasHartDev wants to merge 2 commits into
Open
feat: Add Redis Key-Value Backend With TTL and Sorted Sets#6ThomasHartDev wants to merge 2 commits into
ThomasHartDev wants to merge 2 commits into
Conversation
Model the activity-feed port with HASH users and posts, SET NX handles, bidirectional follow sets, and a per-author ZSET timeline. PEXPIRE is per key, so reads prune dangling timeline members after a post hash expires.
Hydrate now treats a live hash whose author does not match the timeline as expired index data, ZREMs it, and returns null.
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.
Redis store for the same activity-feed contract. Users and posts are hashes, handles are SET NX strings, follows are a pair of sets, and each author timeline is a sorted set scored by createdAt.
Expiry is per key. PEXPIRE drops the post hash and leaves the zset member until the next timeline read removes it. After TTL the post id can be published again, including by a different author. Hydrate only returns a hash whose authorId matches the timeline being read; a reused id is ZREMed from the old author's zset so postsByAuthor and follower feeds do not leak someone else's post.
MemoryRedis is an in-process engine so the contract and the TTL cases run without a daemon.
Closes #5.