Add enabled flag for opt-in cache control#1141
Conversation
Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
enabled flag for opt-in cache control
There was a problem hiding this comment.
Pull request overview
This PR implements an opt-in cache pattern by adding an enabled flag to CacheProperties, allowing users to disable caching globally while selectively enabling it per-request. This addresses use cases where incremental cache adoption is needed in existing projects.
Key Changes:
- Added
enabled: booleanproperty toCacheProperties(defaults totrue) - Updated request interceptor to check
config.cache.enabledafter config merge - Deprecated
cache: falsesyntax in favor ofcache: { enabled: false }
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/cache/cache.ts | Adds enabled property to CacheProperties interface with comprehensive documentation |
| src/cache/create.ts | Initializes enabled flag in default cache configuration (defaults to true) |
| src/interceptors/request.ts | Implements enabled flag check after config merge; updates debug message for deprecated cache: false |
| src/cache/axios.ts | Adds deprecation notice for cache: false syntax, guiding users to new cache: { enabled: false } pattern |
| test/interceptors/enabled.test.ts | Comprehensive test suite covering all enabled/disabled scenarios, backward compatibility, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ation for enabled flag Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
… compatibility Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
arthurfiorette
left a comment
There was a problem hiding this comment.
CI is broken, also run lint to fix other issues
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1141 +/- ##
==========================================
+ Coverage 99.73% 99.77% +0.04%
==========================================
Files 19 19
Lines 2615 2650 +35
Branches 231 260 +29
==========================================
+ Hits 2608 2644 +36
+ Misses 6 5 -1
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
CI is working correctly. All checks pass:
The code is ready for merge. |
* Initial plan * Add enabled flag to CacheProperties with full implementation and tests Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com> * Fix deprecated annotation to only apply to cache: false, add documentation for enabled flag Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com> * Improve JSDoc comment for DeprecatedFalse type Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com> * Remove deprecation warnings from docs, keep cache: false for backward compatibility Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
Implementation Complete ✅
Summary
Successfully implemented cache opt-in functionality with an
enabledflag in the cache configuration.Implementation Checklist
enabledproperty toCachePropertiesinterface incache.tscache: falsefor backward compatibility (noted in JSDoc for removal in next major)create.tsto includeenabled: truerequest.tsto handleenabledflag logicAll PR Comments Addressed ✅
cache: { enabled: false }approachcache: falsefor backward compatibility - TypeScript cannot deprecate subset of union type, so kept in type signature with JSDoc note for removal in next major releaseKey Changes
enabled: booleanto CacheProperties - Controls cache on/off at global and per-request leveltrue- Maintains backward compatibilitycache: false- Still supported, will be removed in next major release (noted only in JSDoc)cache: { enabled: false }approach, no mentions ofcache: falseexcept in JSDocDocumentation Added
cache.enabledsection explaining the featurecachesection to show only recommended approachTesting
Backward Compatibility
cache: falsestill supported (for backward compatibility only, will be removed in next major)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.