Data stores, lifecycles, and caching
DVA-C03 · Lesson 8 of 24 · 1:02:27
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the DVA-C03 exam (AWS Certified Developer – Associate). In this lesson: choosing a data store from access patterns (DynamoDB, RDS and Aurora, S3, ElastiCache, OpenSearch Service, Athena), DynamoDB TTL, S3 lifecycle rules, log and backup retention, lazy loading and write-through caching, key TTLs, DAX, and CloudFront. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Data with a life cycle
AnyCompany Tickets keeps orders, seating plans, ticket PDFs, sales reports, and logs, and each kind of data is read in its own way. Data also has a life: a seat hold expires after ten minutes, a ticket PDF is rarely opened once the event is over, and logs only matter for a few months. This lesson covers how to choose a data store from the access patterns, how to manage data lifecycles, and how to cache data with lazy loading or write-through.
Choosing a data store
Start from the access patterns: which questions the app asks, how often, and how fast it needs the answers. DynamoDB serves key-value and document data at any scale, with single-digit millisecond reads, when the access patterns are known in advance. Amazon RDS and Aurora are relational: joins, transactions across tables, and ad hoc SQL queries. S3 stores files and objects of any size, at low cost, with lifecycle rules, and Athena can query them with SQL. ElastiCache keeps hot data in memory, for sub-millisecond reads, and OpenSearch Service handles full-text search.
Lifecycles and retention
In DynamoDB, Time to Live, or TTL, deletes items after a timestamp that you store in an attribute, in Unix epoch seconds. The deletion runs in the background, typically within a few days after expiry, without consuming write throughput, so reads should filter out expired items. In S3, lifecycle rules move objects to cheaper storage classes, like the Glacier classes, and expire them, including old versions. In CloudWatch Logs, data is kept forever by default, so set a retention period on each log group. And RDS keeps automated backups for the retention period that you choose.
Caching strategies
With lazy loading, the app reads the cache first. On a miss, it reads the database and writes the result to the cache, so only data that is actually requested gets cached. The cost is an extra trip on each miss, and data that can go stale when the database changes. With write-through, the app updates the cache every time it writes to the database, so cached data stays current, but every write pays the extra step, and the cache fills with data that may never be read. Most apps combine them, with a TTL on each key, which limits both staleness and the size of the cache.
Caching services
ElastiCache runs Valkey, Redis OSS, or Memcached, as a serverless cache or on nodes, for query results, sessions, and counters. DynamoDB Accelerator, or DAX, is an in-memory cache in front of a DynamoDB table, with the same API, so reads drop to microseconds with few code changes. CloudFront caches content close to the users, and API Gateway can cache the responses of a REST API stage. Lesson twenty-four comes back to caching, to fix performance bottlenecks.
AnyCompany Tickets data map
Here is the data map of AnyCompany Tickets. Orders and seat holds are stored in DynamoDB, with TTL on the holds, and ticket PDFs sit in S3, with a lifecycle rule that moves them to a Glacier class after the event. Sales reports come from Aurora, with automated backups, and logs have a retention of ninety days in CloudWatch Logs. And seat counts are cached in ElastiCache, with a short TTL on each key.
Recap
Let's recap. Choose a store from the access patterns: DynamoDB for known keys at scale, RDS and Aurora for joins and transactions, and S3 for objects. DynamoDB TTL deletes expired items in the background, so filter them out on reads. S3 lifecycle rules move and expire objects, and log groups and backups need a retention period. Lazy loading caches what is read, write-through keeps the cache current, and a TTL on each key limits staleness. And ElastiCache, DAX, CloudFront, and API Gateway caching each cache a different layer.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Seat holds are items in a DynamoDB table, and each hold must expire ten minutes after it is created. The team wants no cleanup job, and the app must never show an expired hold. What should the developer do?
- Run a scheduled scan that deletes old holds
- Add an S3 lifecycle rule for the hold items
- Set TTL on an expiry attribute and filter reads
- Set TTL on an expiry attribute, nothing else
Show the answer
Set TTL on an expiry attribute and filter reads
TTL deletes the expired holds with no job to run, and a filter on the expiry time hides those that are not deleted yet. “Run a scheduled scan that deletes old holds” would need a scheduled job, which the team wants to avoid, and scans cost a lot. “Add an S3 lifecycle rule for the hold items” would apply to objects in S3, not to items in a table. And “Set TTL on an expiry attribute, nothing else” would rely on TTL alone, and the app could still show holds that expired minutes ago.
The app caches venue details with lazy loading. After an update to a venue, the old details keep showing until the cache entry expires. Updates are rare, and the cache must always match the database. Which strategy should the developer add?
- Write-through on each venue update
- No TTL on any of the cache keys
- A larger node type for the cache cluster
- A read replica for the venue database
Show the answer
Write-through on each venue update
With write-through, each update to a venue also refreshes its cache entry, so the cache matches the database. “No TTL on any of the cache keys” would keep old data forever, the opposite of the goal. “A larger node type for the cache cluster” would hold more entries, and they would be just as stale. And “A read replica for the venue database” would spread the database reads, without touching the stale entries in the cache.
The finance team needs monthly reports that join orders, customers, and venues, and refunds must update several tables in one transaction. Which data store fits these needs?
- DynamoDB, with a scan for each report
- ElastiCache, with the data held in memory
- S3 Glacier Deep Archive, as the store
- Amazon Aurora, with a relational schema
Show the answer
Amazon Aurora, with a relational schema
Aurora is relational, with joins, ad hoc SQL, and transactions across tables. “DynamoDB, with a scan for each report” would need the joins done in the code, and full table scans for each report. “ElastiCache, with the data held in memory” would keep data in memory, as a cache, and not as the system of record. And “S3 Glacier Deep Archive, as the store” would archive data for rare access, far from monthly reports.