-
Notifications
You must be signed in to change notification settings - Fork 1
Add caching to user experiments fetch function #595
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #595 +/- ##
==========================================
+ Coverage 96.28% 96.29% +0.01%
==========================================
Files 48 48
Lines 1882 1889 +7
==========================================
+ Hits 1812 1819 +7
Misses 70 70 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot Why is the codecov failing? |
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 adds caching functionality to the get_experiments_for_user_number function to reduce unnecessary API calls and improve performance. The implementation uses Redis/Valkey caching with a configurable TTL (default 120 seconds).
Changes:
- Added cache lookup before making external API requests using
cache_get_json - Implemented cache storage for successful API responses using
cache_set_json - Added configurable TTL via
AUTH_EXPERIMENTS_CACHE_TTL_SECONDSenvironment variable - Updated tests to cover caching scenarios including cache hits, misses, and failed requests
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| fia_api/core/auth/experiments.py | Adds caching logic with cache key generation, cache lookup, and cache storage for successful responses |
| test/core/auth/test_experiments.py | Adds comprehensive test coverage for caching behavior including cache hits, misses, and verification that failed requests are not cached |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes None (continuation of caching logic).
Description
Adds caching to the
get_experiments_for_user_numberfunction in thefia_api.core.auth.experimentsmodule to improve efficiency by avoiding unnecessary API calls. Makes use ofcache_get_jsonandcache_set_json, with a configurable TTL via theAUTH_EXPERIMENTS_CACHE_TTL_SECONDSenvironment variable. The function now first checks the cache before making an external request and caches successful responses.