Start a new topic

What is difference between setting the cache policy in the store or the query

My store is setup with `KCSStoreCachePolicy:@(KCSCachePolicyLocalFirst)`. Whenever I simply query on it, the completion block is executed in the main thread, but if I use `query cachePolicy:KCSCachePolicyLocalFirst` the completion block runs in a different thread. I'm doing a bunch of queries updating the UI in their completion block. Do I have to setup a store for each query?
1 Comment

Setting the cache policy as a store option means that policy will be used as the default for loads and queries. If you specify a different cache policy in a specific query message, that one will be used instead.

The thread that the callback is executed on probably depends on whether the request is fulfilled from the cache or the network, and you should not rely on the callbacks happening on an specific thread. In your case you should explicitly update the UI on the main thread.

Login or Signup to post a comment