Skip to main content

Is there a fetch policy for getCustomerInfo that translates to,

  1. Go to network, get the most recent
  2. If network fails, use cache if not stale
  3. Return error if cache is stale

Basically, “fetchedOrNotStaleCached”, borrowing from the policy names below. Is there any reason this is not supported (so I don’t try to create it through extra code either)? I thought maybe a rate limit is behind this, but not sure now (it seems a rate limit of 5 minutes for this type of policy for example would become effectively “notStaleCachedOrFetched”).    

public enum CacheFetchPolicy: Int {

/// Returns values from the cache, or throws an error if not available.
case fromCacheOnly

/// Always fetch the most up-to-date data.
case fetchCurrent

/// Returns the cached data if available and not stale, or fetches up-to-date data.
/// - Warning: if the cached data is stale, and fetching up-to-date data fails (if offline, for example)
/// an error will be returned instead of the outdated cached data.
case notStaleCachedOrFetched

/// Default behavior: returns the cached data if available (even if stale), or fetches up-to-date data.
case cachedOrFetched

/// Default ``CacheFetchPolicy`` behavior.
public static let `default`: Self = .cachedOrFetched

}

 

This is how we cache customerInfo: https://www.revenuecat.com/docs/test-and-launch/debugging/caching#customerinfo

We don’t have the fetch policy you’re describing, mostly due to performance reasons (that method can be called many times throughout the app’s lifecycle, which would lead to many network calls), so you many need to build this behavior yourself.


Reply