CachePolicy enum
How BifrostRepository.fetch balances the network against the disk cache.
Values
- networkFirst → const CachePolicy
-
Request the network; fall back to cache when the request fails.
The default, and the fix for the pre-0.9 behaviour that keyed fallback on
ConnectionChecker.isConnected. Being online is not the same as the request working — a captive portal, a downed server, or DNS failure all report connected while returning nothing usable.Fallback covers transport failures and 5xx only. A 4xx is a definitive answer from the server, and serving stale data would hide it.
The caller cannot tell a fallback apart from a fresh response. A fallback is returned as
BifrostSuccess, exactly like a live 200 — there is no flag on the result saying "this came from cache after a failure."bind()therefore setsRxStatus.success()either way. Before this cache policy existed, fallback only happened while genuinely offline; now a 500 or a captive portal can silently render stale data as current, with nothing in the UI to say so. Surfacing that distinction to callers (e.g. a field on BifrostSuccess) is a design change, not fixed here — see the cache-policy table in the bifrost_app brick's ARCHITECTURE.md for the same caveat. - cacheFirst → const CachePolicy
-
Serve a fresh cache entry without touching the network.
"Fresh" means within
cacheDuration. This is the policy that makes that parameter meaningful — under networkFirst it only bounds the fallback. - networkOnly → const CachePolicy
-
Never read or write the cache.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
CachePolicy> - A constant List of the values in this enum, in order of their declaration.