Skip to content

Conversation

@zto-sbenning
Copy link
Contributor

…ion context

  • Add SetContext type with isInitialHydration flag
  • Update Handler interface to accept optional SetContext in set()
  • Implement NX behavior in redis-strings handler when isInitialHydration is true
  • Update all handlers (local-lru, composite) to accept ctx parameter
  • Propagate isInitialHydration flag from registerInitialCache to handlers
  • Prevents runtime cache overwrites during app restarts and horizontal scaling

Addresses #23

…ion context

- Add SetContext type with isInitialHydration flag
- Update Handler interface to accept optional SetContext in set()
- Implement NX behavior in redis-strings handler when isInitialHydration is true
- Update all handlers (local-lru, composite) to accept ctx parameter
- Propagate isInitialHydration flag from registerInitialCache to handlers
- Prevents runtime cache overwrites during app restarts and horizontal scaling

Addresses fortedigital#23
@zto-sbenning
Copy link
Contributor Author

Hi @AyronK,

I've implemented a solution for #23 . I'd really appreciate your thoughts on this implementation before marking it as ready for review.

Approach chosen

Instead of adding the option to registerInitialCache settings (as initially suggested), I followed your comment about preferring "config on redis handler or env variable" by implementing this at the handler level:

  • Added a new SetContext type with an isInitialHydration flag
  • Updated the Handler interface to accept optional context in set()
  • registerInitialCache passes isInitialHydration: true when hydrating
  • Redis handler uses NX option when this flag is set
  • All handlers updated to accept the context (backward compatible)

Happy to adjust anything - just wanted to get your feedback on the architecture first!

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