Read-Through vs. Write-Through (Cache) Flashcards

(11 cards)

1
Q

Why would you care about the implementation of a read-through vs a write-through cache?

A

Choosing between read-vs-write can be an important optimization where speed is critical.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does a read-through cache work? Can you walk through the process?

A

A read-through cache is populated on-demand.

Basically when a request is made, the cache would:
- Check for the requested item
- If missed, it would query primary storage, store in the cache, and serve
- If hit, it would serve directly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the pros of a read-through cache?

A

It’s transparent (since the application only interacts with the cache), highly performant on hits (served directly from the cache), and reduces primary storage pressure (frequent reads don’t hit primary storage).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s the single con of a read-through cache?

A

Misses result in a latency hit as the data must be read from primary storage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does a write-through cache work? Can you walk through the process?

A

In a write-through cache, all write operations are written to the cache AND primary storage.

When a write request is made:
- Data is written to the cache
- Data is written to the primary storage
- All reads are made from the cache

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three primary pros of using write-through cache?

A

A write-through cache provides:
- Consistency guarantees as the cache and primary storage are always in sync
- No data is lost during crashes as both stores have the same data
- Simplfied writes as it’s written to the cache and primary storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two cons of a write-through cache?

A

Writes can have higher latency as they must be written to two places instead of one, and since every write hits primary storage it can increase pressure on it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of systems would favor a read-through cache?

A

Most read-heavy systems would prefer a read-through, especially if data isn’t frequently updated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What systems would prefer a write-through cache?

A

Systems that favor consistency or data integrity would favor a write-through cache, even at the cost of increased write latency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are two good reasons to use a read-through cache?

A

Ready-heavy with infrequent writes and eventually consistent with reads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are two good reason to use a write-through cache?

A

Systems where data consistency is paramount and updates must be immediately propagated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly