PFCachePolicy

enum PFCachePolicy : uint8_t {}

PFCachePolicy specifies different caching policies that could be used with PFQuery.

This lets you show data when the user’s device is offline, or when the app has just started and network requests have not yet had time to complete. Parse takes care of automatically flushing the cache when it takes up too much space.

Warning

Cache policy could only be set when Local Datastore is not enabled.

See

PFQuery

  • The query does not load from the cache or save results to the cache. This is the default cache policy.

    Declaration

    Objective-C

    kPFCachePolicyIgnoreCache = 0
  • The query only loads from the cache, ignoring the network. If there are no cached results, this causes a NSError with kPFErrorCacheMiss code.

    Declaration

    Objective-C

    kPFCachePolicyCacheOnly
  • The query does not load from the cache, but it will save results to the cache.

    Declaration

    Objective-C

    kPFCachePolicyNetworkOnly
  • The query first tries to load from the cache, but if that fails, it loads results from the network. If there are no cached results, this causes a NSError with kPFErrorCacheMiss code.

    Declaration

    Objective-C

    kPFCachePolicyCacheElseNetwork
  • The query first tries to load from the network, but if that fails, it loads results from the cache. If there are no cached results, this causes a NSError with kPFErrorCacheMiss code.

    Declaration

    Objective-C

    kPFCachePolicyNetworkElseCache
  • The query first loads from the cache, then loads from the network. The callback will be called twice - first with the cached results, then with the network results. Since it returns two results at different times, this cache policy cannot be used with synchronous or task methods.

    Declaration

    Objective-C

    kPFCachePolicyCacheThenNetwork