VariantLookupPolicy
public enum VariantLookupPolicy
Strategy for resolving feature flag variants relative to the on-disk persistence layer and the network.
networkOnly: Never read or write persisted variants. Variant lookups always wait for the network call. Default; matches behavior prior to variant persistence. If a persisted blob exists from a previous session that used a persisting policy, it’s wiped on init.persistenceUntilNetworkSuccess(persistenceTtl:): Serve persisted variants immediately when available, refresh from the network in the background. Persisted entries older thanpersistenceTtlare ignored on read but NOT deleted (the next successful fetch overwrites them).networkFirst(persistenceTtl:): Prefer fresh values from the network, but fall back to persisted variants when the network call fails. Same TTL semantics aspersistenceUntilNetworkSuccess.
TTL handling — non-positive persistenceTtl on a persisting policy is a
misconfiguration. At SDK init the requested policy is run through effective(_:), which
collapses any persisting policy with persistenceTtl <= 0 to .networkOnly (with a
warning logged). Persistence-with-no-useful-TTL would write to disk on every fetch but
never serve anything from disk, so the SDK substitutes the meaningful interpretation. The
factories themselves don’t sanitize — they preserve exactly what the developer asked for
so callers can introspect.
Convenience zero-argument forms persistenceUntilNetworkSuccess() / networkFirst() use
defaultTTL (24 hours) — equivalent to passing
persistenceTtl: VariantLookupPolicy.defaultTTL.
-
Undocumented
Declaration
Swift
case networkOnly -
Undocumented
Declaration
Swift
case persistenceUntilNetworkSuccess(persistenceTtl: TimeInterval) -
Undocumented
Declaration
Swift
case networkFirst(persistenceTtl: TimeInterval) -
Default time-to-live for persisted variants when no TTL is specified: 24 hours.
Declaration
Swift
public static let defaultTTL: TimeInterval -
Convenience constructor — equivalent to
.persistenceUntilNetworkSuccess(persistenceTtl: VariantLookupPolicy.defaultTTL).Declaration
Swift
public static func persistenceUntilNetworkSuccess() -> VariantLookupPolicy -
Convenience constructor — equivalent to
.networkFirst(persistenceTtl: VariantLookupPolicy.defaultTTL).Declaration
Swift
public static func networkFirst() -> VariantLookupPolicy
View on GitHub
Install in Dash