QuestionQ266

Analyzing and optimizing technical and business processes

You are deploying a PHP App Engine Standard service that uses Cloud SQL as its backend. You want to minimize the number of database queries.

What should you do?

  • A Set the memcache service level to dedicated. Create a key from the hash of the query, and return database values from memcache before issuing a query to Cloud SQL.
  • B Set the memcache service level to dedicated. Create a cron task that runs every minute to populate the cache with keys containing query results.
  • C Set the memcache service level to shared. Create a cron task that runs every minute to save all expected queries to a key called ג€cached_queriesג€.
  • D Set the memcache service level to shared. Create a key called ג€cached_queriesג€, and return database values from the key before using a query to Cloud SQL.
Explanation

A cache-aside implementation uses a distinct key, such as a hash of the query, to look up a cached result before accessing Cloud SQL. A cache hit avoids the database query; on a cache miss, the application can query Cloud SQL and cache the result for later requests. Dedicated memcache provides cache capacity exclusively assigned to the application, while shared memcache is best-effort.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!