问题
I've been using firebase with cloud functions recently and this question popped into my mind.
If in my cloud function, using the Firebase Admin SDK, perform multiple reads to the same document in a single function call, will it count as multiple reads in the database or will it cache the data?
Example:
await admin.firestore().collection("users").doc("user_id_here").get();
await admin.firestore().collection("users").doc("user_id_here").get();
await admin.firestore().collection("users").doc("user_id_here").get();
Will this code above cause multiple reads or only one?
回答1:
The Firebase/Cloud server SDKs don't do any persistent caching like the Firebase client SDKs. What you've written will perform three document reads.
来源:https://stackoverflow.com/questions/59146727/does-firebase-admin-sdk-perform-any-caching