Reputation: 93
I would like to access Firestore cached data. I am able to do so using the following code:
db.collection("users").document(userID).get(Source.CACHE)
.addOnCompleteListener { task ->
// Access data here
}
However, this gets data asynchronously (but almost instantly). I would like to return this cached data in a synchronous function. Is there a possible way to do this?
Upvotes: 0
Views: 43
Reputation: 598728
While data access from the cache is local, it still requires reading from disk, which may be a lot slower for some of your users than you are experiencing.
There is no way to get data from Firestore (cached or not) with a synchronous call. You will have to deal with the asynchronous nature of the API.
Upvotes: 1