refactor: reuse single discourse cache across API instances - #2831
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the Flask app’s Discourse integrations to reduce duplicated ResponseCache instances by introducing a shared cache (and a shared TTL constant) for multiple DiscourseAPI clients.
Changes:
- Added a
CACHE_TTLconstant inwebapp/utils/constants.pyfor cache TTL configuration. - Created a single
ubuntu_discourse_cacheinwebapp/app.pyand reused it across severalDiscourseAPIinstances. - Set
cache=Nonefor thediscuss.kubernetes.ioDiscourse instance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| webapp/utils/constants.py | Introduces a shared cache TTL constant for ResponseCache configuration. |
| webapp/app.py | Reuses a single ResponseCache across multiple Discourse API instances and adjusts caching behavior for an instance without API keys. |
Comments suppressed due to low confidence (1)
webapp/app.py:1172
- PR description says Discourse instances without API keys should have
cache=None, but this instance does not passapi_key/api_usernameand still uses the shared cache.
cache=ubuntu_discourse_cache,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2831 +/- ##
==========================================
+ Coverage 74.63% 74.65% +0.02%
==========================================
Files 19 19
Lines 2377 2379 +2
==========================================
+ Hits 1774 1776 +2
Misses 603 603
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
43cf781 to
7caf60b
Compare
6aaca5c to
ba55d13
Compare
ba55d13 to
65596b5
Compare
Done
NoneQA
Issue / Card
Fixes WD-37940
Screenshots
[if relevant, include a screenshot]