All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.revenuecat.purchases.kmp.models.CacheFetchPolicy.kt Maven / Gradle / Ivy

There is a newer version: 1.3.7+13.15.0
Show newest version
package com.revenuecat.purchases.kmp.models

/**
 * Specifies behavior for a caching API.
 */
public enum class CacheFetchPolicy {
    /**
     * Returns values from the cache, or throws an error if not available. It won't initiate a fetch.
     */
    CACHE_ONLY,

    /**
     * Ignore whether the cache has a value or not and fetch the most up-to-date data. This will return an
     *  error if the fetch request fails
     */
    FETCH_CURRENT,

    /**
     * Returns the cached data if available and not stale. If not available or stale,
     *  it fetches up-to-date data. Note that this won't return stale data even if fetch request fails
     */
    NOT_STALE_CACHED_OR_CURRENT,

    /**
     * (default) returns the cached data if available (even if stale). If not available, fetches
     *  up-to-date data. If cached data is stale, it initiates a fetch in the background.
     */
    CACHED_OR_FETCHED,

    ;

    public companion object {
        /**
         * Returns the default policy when no policy is provided.
         */
        public fun default(): CacheFetchPolicy = CACHED_OR_FETCHED
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy