-
Notifications
You must be signed in to change notification settings - Fork 0
Release 20250727 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 20250727 #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a Redis pub/sub system for cache invalidation and introduces Redis client functionality. The changes add the ability to subscribe to cache eviction messages and automatically clear both plan and contact caches when triggered.
- Adds Redis client with pub/sub capabilities for cache management
- Implements cache clearing functions for plan and contact data
- Integrates cache subscriber into the FastAPI application lifecycle
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/redis/subscriber.py | Implements cache clearing subscriber that listens for eviction messages |
| src/redis/client.py | Provides Redis client with connection, publish, and subscribe functionality |
| src/redis/init.py | Exports Redis module components |
| src/plan/cache.py | Adds cache clearing function for plan data |
| src/contact_us/init.py | Adds cache clearing function and renames cache getter for consistency |
| src/config/init.py | Adds Redis configuration settings |
| main.py | Integrates Redis subscriber into application lifecycle and fixes import case |
| if rds.pubsub: | ||
| await rds.pubsub.unsubscribe(channel) |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The finally block checks rds.pubsub but should check pubsub (the local variable from line 12). This could cause the unsubscribe to not execute when rds.pubsub is None but pubsub exists.
| if rds.pubsub: | |
| await rds.pubsub.unsubscribe(channel) | |
| if pubsub: | |
| await pubsub.unsubscribe(channel) |
| if rds.pubsub: | ||
| await rds.pubsub.unsubscribe(channel) |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the local pubsub variable instead of rds.pubsub to ensure proper cleanup of the subscription created in this function.
| if rds.pubsub: | |
| await rds.pubsub.unsubscribe(channel) | |
| if pubsub: | |
| await pubsub.unsubscribe(channel) |
| logger.error("rds connect failed") | ||
| return | ||
|
|
||
| asyncio.create_task(cache_clear_subscriber()) |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The created task is not stored or awaited, which means there's no way to handle exceptions or ensure proper cleanup. Consider storing the task reference for better lifecycle management.
| asyncio.create_task(cache_clear_subscriber()) | |
| task = asyncio.create_task(cache_clear_subscriber()) | |
| task.add_done_callback(lambda t: logger.error(f"Task cache_clear_subscriber failed: {t.exception()}") if t.exception() else logger.info("Task cache_clear_subscriber completed successfully")) |
|
|
||
| async for message in pubsub.listen(): | ||
| if message["type"] == "message": | ||
| logger.info("evict message received: {}".format(message)) |
Copilot
AI
Jul 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Use f-string formatting instead of .format() for consistency with the rest of the codebase (as seen in lines 26 and 30).
| logger.info("evict message received: {}".format(message)) | |
| logger.info(f"evict message received: {message}") |
No description provided.