feat: add CacheStrategy system for fine-grained cache control#10
Merged
feat: add CacheStrategy system for fine-grained cache control#10
Conversation
Introduces a CacheStrategy enum with two strategies: - cacheFirst (default): Uses cache if available, otherwise fetches from network - networkFirst: Always tries network first, falls back to cache on failure Key changes: - Added CacheStrategy enum with documentation - Added strategy parameter to call() method - Implemented networkFirst with expired cache fallback - Added comprehensive tests for both strategies - Updated README with usage examples and API docs Closes #6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
- Coverage 90.09% 88.80% -1.30%
==========================================
Files 3 3
Lines 101 125 +24
==========================================
+ Hits 91 111 +20
- Misses 10 14 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the
CacheStrategysystem as requested in #6, giving developers fine-grained control over how data is retrieved from cache vs remote source.Changes
CacheStrategyenum with two strategies:cacheFirst(default): Uses cache if available and valid, otherwise fetches from networknetworkFirst: Always tries network first, falls back to cache (even expired) on failurestrategyparameter tocall()methodnetworkFirstthat uses expired cache data when network failsUsage Example
Backward Compatibility
cacheFirst, preserving existing behaviorTest plan
cacheFirststrategy behaviornetworkFirststrategy behaviorCloses #6
🤖 Generated with Claude Code