Caching Flashcards

(10 cards)

1
Q

What is caching?

A

Caching stores frequently accessed data in a fast-access layer (memory) to reduce latency and load on the primary data source. It trades memory for speed.

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

What are the different types of cache?

A

Main types: Client-side cache (browser), CDN cache (edge servers), Application cache (Redis/Memcached), Database cache (query results), CPU cache (hardware level).

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

What is cache invalidation?

A

Cache invalidation is removing or updating stale data from cache. It’s one of the hardest problems in CS. Strategies include TTL (time-to-live), write-through, and event-based invalidation.

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

What is the difference between cache-aside and write-through?

A

Cache-aside: Application reads from cache, loads from DB on miss, and updates cache. Write-through: Application writes to cache, which synchronously writes to DB. Write-through ensures consistency.

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

What is a CDN (Content Delivery Network)?

A

A CDN is a geographically distributed network of proxy servers that cache content closer to users. It reduces latency, bandwidth costs, and load on origin servers.

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

What is cache eviction?

A

Cache eviction removes items when cache is full. Common policies: LRU (Least Recently Used), LFU (Least Frequently Used), FIFO (First In First Out), Random.

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

What is Redis?

A

Redis is an in-memory data store used as a cache, message broker, and database. It supports various data structures (strings, lists, sets, hashes) and offers persistence options.

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

What is Memcached?

A

Memcached is a distributed memory caching system for speeding up dynamic web applications by reducing database load. It’s simpler than Redis with key-value storage only.

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

When should you not use caching?

A

Avoid caching for: frequently changing data, data requiring strong consistency, large datasets that don’t fit in memory, or when cache overhead exceeds benefits.

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

What is cache stampede?

A

Cache stampede (thundering herd) occurs when many requests simultaneously try to regenerate a cache entry after expiration. Solutions include lock-based regeneration or probabilistic early expiration.

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