Skip to content

fix(cache): invalidate link resolution cache on update and delete#20

Open
RaoUsama7 wants to merge 1 commit intoLinkForty:mainfrom
RaoUsama7:fix/link-cache-invalidation
Open

fix(cache): invalidate link resolution cache on update and delete#20
RaoUsama7 wants to merge 1 commit intoLinkForty:mainfrom
RaoUsama7:fix/link-cache-invalidation

Conversation

@RaoUsama7
Copy link
Contributor

  • Add reusable helper for Redis link-resolution cache invalidation
  • Invalidate cached keys after successful link update and delete
  • Clear both old and new key sets when template association changes
  • Add unit tests for cache invalidation helper behavior

Description

Fix stale redirect and SDK resolve behavior by invalidating Redis link-resolution cache entries when links are updated or deleted.

Previously, the read path cached link JSON for 5 minutes, but link mutation routes did not invalidate those keys. This meant stale redirects or stale SDK resolutions could be served until TTL expiry.

This change adds a small reusable cache invalidation helper and applies it to link update/delete flows.

Type of Change

  • Bug fix / correctness improvement
  • New feature
  • Breaking change
  • Documentation update

Changes Made

  • Add invalidateLinkResolutionCache helper for Redis link-resolution cache keys
  • Invalidate cached link-resolution keys after successful link update
  • Invalidate both old and new key sets when template association changes
  • Invalidate cached link-resolution keys after successful link delete
  • Add unit tests for cache invalidation helper behavior

Notes

  • Scope is intentionally minimal and correctness-focused
  • Does not change redirect read-path behavior
  • Does not include stampede protection, negative caching, or broader cache redesign

Testing

  • All tests passing locally

- Add reusable helper for Redis link-resolution cache invalidation
- Invalidate cached keys after successful link update and delete
- Clear both old and new key sets when template association changes
- Add unit tests for cache invalidation helper behavior
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 40.74074% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/routes/links.ts 0.00% 32 Missing ⚠️

📢 Thoughts on this report? Let us know!

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