Closed aliasad106 closed 2 years ago
Please complete the issue template in it's entirety by adding information under each header.
Caching was added in #196. You can change the default cache policy the SDK uses for your app when you initialize the SDK using requestCachePolicy
, cacheMemoryCapacity
, and cacheDiskCapacity
as stated in the [documentation](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/parseswift/initialize\(applicationid:clientkey:masterkey:serverurl:livequeryserverurl:allowingcustomobjectids:usingtransactions:usingequalqueryconstraint:keyvaluestore:requestcachepolicy:cachememorycapacity:cachediskcapacity:migratingfromobjcsdk:deleti-97083/). Details can be found by looking at Apple's documentation. The SDK defaults to Apple's default, useProtocolCachePolicy
If you want to choose a different caching policy for an individual query, simply pass the caching policy option you want to your query:
let options: API.Options = [.cachepolicy(returnCacheDataDontLoad)]
let query = GameScore.query("points" > 50)
let results = try await query.find(options: options)
...
@cbaker6 The apple documentation doesn't really guide how can we achieve cacheThenNetwork. And how can we update our cache with the updated response of query. P.S. How do we use useProtocolCachePolicy with combination to Parse query ?
P.S. How do we use useProtocolCachePolicy with combination to Parse query?
I’ve answered this in the previous comment, it’s automatically used for every query:
The SDK defaults to Apple's default, useProtocolCachePolicy
@cbaker6 But I don't see the cached response, It always fetched from network when we use useProtocolCachePolicy
This is probably because the SDK uses .POST
instead of .GET
for queries: https://github.com/parse-community/Parse-Swift/blob/b0bd3510100f17b2c2b848f4bd6aa189b268ee30/Sources/ParseSwift/Types/Query.swift#L1271-L1447
@cbaker6 I have updated to 4.9.3 and it still doesn't show me cacheThenNetwork
. And by default it always fetches from network.
New Feature / Enhancement Checklist
Current Limitation
The query does not allow me to add cachePolicy cacheThenNetwork as it was implemented there in the Parse iOS/macOS SDK.
Feature / Enhancement Description
When given the .cacheThenNetwork. It will first check from cache and respond and then it will load from network.
Example Use Case
Example use case is. When I load my feeds it first shows from cache and simultaneously fetches from network and respond and it also updates the cache with new data.
Alternatives / Workarounds
No
3rd Party References
Parse