-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add redis caching #587
Add redis caching #587
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.
Overall a good improvement!
Some important things to consider and resolve before merging.
src/api/schemas/response.ts
Outdated
.openapi({ description: 'Start date of reporting period' }), | ||
endDate: z.date().openapi({ description: 'End date of reporting period' }), | ||
endDate: z | ||
.union([z.date(), z.string()]) |
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.
Same thing here with the z.string().date()
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.
👆
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.
Thanks for these improvements! Good thing we fixed the cache key before deploying 😄
Add Redis Caching
🌍 This PR introduces Redis-based caching for better performance and reduced database load.
Key Updates:
🌍 Companies API:
- Implements Redis cache with dynamic keys tied to latestMetadataUpdatedAt.
- Reduces redundant database queries by serving cached data when available.
🌍 Municipalities API:
- Adds Redis cache with a static key since data is immutable.
- Enhances performance with faster responses for repeated requests.
Benefits:
🌍 Optimized server performance.
🌍 Simplified cache management with automatic invalidation for updates.
🌍 Scalable design leveraging Redis.
🏠 Updated the readme with a quick setup for redis insight. Where you can inspect you redis data
Testing:
✅ Verified caching works for /companies and /municipalities APIs.
✅ Ensured no impact on existing ETag implementation.