Skip to content

feat: Add Redis Key-Value Backend With TTL and Sorted Sets - #6

Open
ThomasHartDev wants to merge 2 commits into
mainfrom
thomas/feat/redis
Open

feat: Add Redis Key-Value Backend With TTL and Sorted Sets#6
ThomasHartDev wants to merge 2 commits into
mainfrom
thomas/feat/redis

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Redis key-value backend with data structures and expiry

1 participant