PFCachePolicy
Objective-C
enum PFCachePolicy : uint8_t {}
Swift
enum PFCachePolicy : UInt8, @unchecked Sendable
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 = 0Swift
case ignoreCache = 0 -
The query only loads from the cache, ignoring the network. If there are no cached results, this causes a
NSErrorwithkPFErrorCacheMisscode.Declaration
Objective-C
kPFCachePolicyCacheOnlySwift
case cacheOnly = 1 -
The query does not load from the cache, but it will save results to the cache.
Declaration
Objective-C
kPFCachePolicyNetworkOnlySwift
case networkOnly = 2 -
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
NSErrorwithkPFErrorCacheMisscode.Declaration
Objective-C
kPFCachePolicyCacheElseNetworkSwift
case cacheElseNetwork = 3 -
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
NSErrorwithkPFErrorCacheMisscode.Declaration
Objective-C
kPFCachePolicyNetworkElseCacheSwift
case networkElseCache = 4 -
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
kPFCachePolicyCacheThenNetworkSwift
case cacheThenNetwork = 5
View on GitHub
Install in Dash