Skip to content

Conversation

@Dagonite
Copy link
Collaborator

@Dagonite Dagonite commented Jan 27, 2026

Closes None (continuation of caching logic).

Description

Adds caching to the get_experiments_for_user_number function in the fia_api.core.auth.experiments module to improve efficiency by avoiding unnecessary API calls. Makes use of cache_get_json and cache_set_json, with a configurable TTL via the AUTH_EXPERIMENTS_CACHE_TTL_SECONDS environment variable. The function now first checks the cache before making an external request and caches successful responses.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.29%. Comparing base (d15484e) to head (a804704).
⚠️ Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dagonite Dagonite changed the title Add caching to user experiments fetch function Add cacheing to user experiments fetch function Jan 28, 2026
@Dagonite Dagonite changed the title Add cacheing to user experiments fetch function Add caching to user experiments fetch function Jan 28, 2026
@Dagonite
Copy link
Collaborator Author

@copilot Why is the codecov failing?

Copy link

Copilot AI commented Jan 28, 2026

@Dagonite I've opened a new pull request, #597, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a 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_SECONDS environment 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.

@Pasarus Pasarus merged commit 5ef32f7 into main Feb 3, 2026
16 checks passed
@Pasarus Pasarus deleted the further-caching branch February 3, 2026 14:38
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.

3 participants