Google Cloud Professional Cloud Developer — Question 354
You are a developer at an ecommerce company. You are tasked with developing a globally consistent shopping cart for logged-in users across both mobile and desktop clients. You need to configure how the items that are added to users’ carts are stored. How should you configure this cart service?
Answer options
- A. Store the carts in a separate Memorystore for Redis instance, and configure each user's IP address as the key.
- B. Store the carts in a separate Firestore document, and configure each user ID as the document's key.
- C. Insert the carts in a separate Spanner table, and configure each user's encrypted password as the primary key.
- D. Create and store the carts in the shopping-cart HTTP cookie.
Correct answer: B
Explanation
The correct answer is B because using Firestore allows for efficient storage and retrieval of user-specific data, with user IDs providing a unique and secure key. Option A is not suitable because IP addresses can change and are not unique to a user. Option C is inappropriate since using passwords as keys introduces security risks, and option D is limited by cookie size restrictions and is not secure for storing cart data.