DVA-C02 - Development with AWS Services - Section 1.10

Apply caching strategies such as lazy loading, write-through and time to live using Amazon ElastiCache and DynamoDB Accelerator in application code.

Apply lazy loading and write-through caching strategies using Amazon ElastiCache and DynamoDB Accelerator to reduce read latency and database load. Distinguish which strategy suits read-heavy versus write-heavy access patterns, and configure time to live to prevent stale data.

Lazy loadingWrite-through cachingDynamoDB AcceleratorAmazon ElastiCache

Practice question for this objective

Free sampleDevelopment with AWS Servicesmedium

A developer uses lazy loading with Amazon ElastiCache for a catalogue service. Because items are only refreshed on a cache miss, an item that changes in the database can remain stale in the cache indefinitely if it keeps being read. The developer wants a simple way to bound how long any cached item can be out of date, without changing the write path. Which change achieves this?

  • ASet a time to live on each cached item so it expires after a fixed interval and the next read reloads the current value from the database. Correct
  • BIncrease the time to live on each cached item to a much larger value so the cache retains items longer and serves more reads from memory.
  • CRemove any time to live so cached items never expire and the application avoids the cost of repeatedly reloading items from the database.
  • DSwitch reads to use a conditional get that compares a stored version attribute and reloads only when the database version is newer.
Apply a time to live to cached items so lazy loading has a bounded maximum staleness for data that keeps being read. A time to live causes each cached entry to expire after a set period, forcing the next read to miss and reload current data from the database, so it caps the staleness window that lazy loading otherwise leaves open for frequently read items.

Why A is correct: A time to live forces each cached item to expire after a fixed interval, so the next read misses and reloads fresh data, capping how long a stale item can be served without touching the write path.

Why B is wrong: A larger time to live keeps items in the cache longer and so increases, rather than bounds, the maximum staleness, which is the opposite of the stated requirement.

Why C is wrong: Removing expiry means a stale item under lazy loading can live in the cache forever while it keeps being read, which is exactly the staleness the developer wants to bound.

Why D is wrong: ElastiCache get operations do not perform a server-side version comparison against the database, so this adds a read to the database on every request and defeats the cache.

See more DVA-C02 practice questions, answers explained.

More in this domain

Back to all Development with AWS Services objectives, or the DVA-C02 cert hub.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.