Class VariantLookupPolicy

java.lang.Object
com.mixpanel.android.mpmetrics.VariantLookupPolicy
Direct Known Subclasses:
VariantLookupPolicy.NetworkFirst, VariantLookupPolicy.NetworkOnly, VariantLookupPolicy.PersistenceUntilNetworkSuccess

public abstract class VariantLookupPolicy extends Object
Configures how the SDK resolves feature flag variants relative to the on-disk persistence layer and the network.

Three strategies are supported:

  • VariantLookupPolicy.NetworkOnly - never read or write persisted variants. Variant lookups always wait for the network call. This is the default and matches behavior prior to the introduction of variant persistence. Construction also wipes any stale on-disk blob left over from a prior persisting configuration.
  • VariantLookupPolicy.PersistenceUntilNetworkSuccess - serve persisted variants immediately when available, and only block on the network if no persisted variants exist for the current user. The network call still runs in the background to refresh. Persisted entries older than persistenceTtlMillis are not served.
  • VariantLookupPolicy.NetworkFirst - prefer fresh values from the network, but fall back to persisted variants when the network call fails. Persisted entries older than persistenceTtlMillis are not served.

Construct instances via the static factories rather than new:


 VariantLookupPolicy.networkOnly()
 VariantLookupPolicy.persistenceUntilNetworkSuccess(TimeUnit.HOURS.toMillis(24))
 VariantLookupPolicy.networkFirst(TimeUnit.HOURS.toMillis(24))
 

This class is intentionally Java 8 compatible (no sealed keyword) even though the module compiles at source level 17. The package-private constructor prevents external subclassing while leaving the type open for instanceof dispatch at consumer sites.

See Also: