Skip to content

fix(cache): broadcast Clear event over Redis pub/sub to peer instances - #2438

Open
jeranaias wants to merge 1 commit into
0xERR0R:mainfrom
jeranaias:fix/pr-001-fix-cache-broadcast-clear-event-
Open

jeranaias wants to merge 1 commit into
0xERR0R:mainfrom
jeranaias:fix/pr-001-fix-cache-broadcast-clear-event-

Conversation

@jeranaias

Copy link
Copy Markdown

Summary

When RedisExpiringCache.Clear() is called on one instance, it clears the local inner cache and deletes matching Redis keys, but does not notify peer instances subscribed to opts.Channel. Other replicas continue serving stale in-memory entries until TTL expiration.

This change adds an optional backwards-compatible Clear bool (json:"clr,omitempty") field to redisSyncMessage, publishes a clear event on c.opts.Channel from Clear(), and handles msg.Clear in handleSyncMessage() by clearing c.inner.

Changes

  • cache/redis.go

Verification

  • Verified locally via: go test -race -run (?:TestRegression)|(?:^(TestRegression_ClearNotBroadcastToOtherInstances)$) ./cache

Disclosure: Flagged using local static/AI analysis tooling (jeranaias), then manually reviewed, reproduced with a unit test, and verified locally prior to opening this PR.

This branch has not been deployed

No deployments
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.

1 participant