Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new caching policy (Policy.cacheAndRefresh) and refactors Syncache policy execution into a shared internal executor/strategy setup, along with a comprehensive test suite for the new policy.
Changes:
- Introduces
Policy.cacheAndRefresh(always returns cache immediately if present and refreshes in background when online). - Refactors
Syncache.get,getWithMeta, andgetConditionalto use a unified_executePolicy+_FetchStrategyabstraction. - Adds tests covering cache hits, stale hits, offline behavior, background refresh, deduplication, and observer notifications for
cacheAndRefresh.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/syncache/lib/src/policy.dart | Adds the cacheAndRefresh policy and documents expected behavior. |
| packages/syncache/lib/src/syncache.dart | Refactors policy logic into _executePolicy/strategies and implements cacheAndRefresh via shared SWR logic. |
| packages/syncache/test/cache_and_refresh_test.dart | New test coverage for Policy.cacheAndRefresh behavior (get/getWithMeta/watch/observers/dedup). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
108e553 to
fb78dda
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new caching policy (Policy.cacheAndRefresh) to Syncache to always return cached data immediately (if present) while triggering an online background refresh, and refactors policy execution into a unified strategy-based implementation.
Changes:
- Introduces
Policy.cacheAndRefreshin the policy enum with documented behavior. - Refactors
Syncache.get,getWithMeta, and conditional-get paths to use a shared_executePolicy+_FetchStrategyabstraction. - Adds a comprehensive test suite covering cacheAndRefresh behavior (get/getWithMeta/watch/dedup/observer comparisons).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/syncache/lib/src/policy.dart | Adds the new cacheAndRefresh policy and its documentation. |
| packages/syncache/lib/src/syncache.dart | Refactors policy handling into unified execution paths and adds shared stale-while-refresh/cache-and-refresh logic. |
| packages/syncache/test/cache_and_refresh_test.dart | Adds tests validating cacheAndRefresh behavior and observer/dedup semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
fb78dda to
ab59fc0
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new caching policy (Policy.cacheAndRefresh) to the Syncache package, enabling “return cache immediately, but always refresh in the background when online” behavior. This fits into Syncache’s existing policy-driven fetch pipeline and reactive watcher model.
Changes:
- Introduces
Policy.cacheAndRefreshwith documented behavior inpolicy.dart. - Refactors
Syncache.get/getWithMeta/getConditionalpolicy handling into a shared_executePolicy+ strategy pattern and factors out shared SWR/CAR logic. - Adds comprehensive tests covering
cacheAndRefreshbehavior acrossget,getWithMeta,watch, deduplication, and observer notifications.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/syncache/lib/src/policy.dart | Adds the new cacheAndRefresh enum value and documents semantics. |
| packages/syncache/lib/src/syncache.dart | Refactors policy execution into _executePolicy / _executeStaleWhileRefresh and adds strategy types; wires in cacheAndRefresh. |
| packages/syncache/test/cache_and_refresh_test.dart | New test suite validating cacheAndRefresh behavior (including offline, dedup, observers, watch). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| .then((_) { | ||
| _notify(key, isFromCache: false); | ||
| }).catchError((Object e, StackTrace st) { | ||
| _notifyObservers((o) => o.onFetchError(key, e, st)); |
| /// When [skipNotify] is true, the method will not call [_notify] after | ||
| /// cache hits or fetches. This is used by [getWithMeta] since the meta | ||
| /// strategy handles value notifications internally via [_notifyValue], | ||
| /// and [watchWithMeta] handles meta notifications via manual emission. |
No description provided.