Caching Junior

1 / 7

What is a cache, and what are the primary reasons for adding one to a system?

Select the correct answer

1

A load balancer that distributes incoming requests across many backend app servers

2

A fast store of data copies that lowers latency and reduces load on the source

3

A queue that buffers write requests so the backing store is updated asynchronously

4

A backup database replica kept in sync to provide durability if the primary fails

What is the difference between a cache hit and a cache miss, and what do we mean by a 'cold' versus a 'warm' cache?

Select the correct answer

1

Hit finds data in cache, miss does not; cold is unpopulated, warm is populated

2

Hit means data is fresh, miss means data is stale; cold is old, warm is recently written

3

Hit is a successful eviction, miss is a failed one; cold has low memory, warm has high

4

Hit writes to cache, miss reads from cache; cold is slow startup, warm is steady state

What is the difference between memoization and caching?

Select the correct answer

1

Memoization is used for databases while caching applies only to pure side functions.

2

Caching requires manual invalidation but memoization automatically refreshes entries.

3

Memoization stores function results by arguments; caching is the broader concept.

4

Caching only works in memory while memoization always persists its results to disk.

What happens to a cache when it reaches its memory limit but no TTLs have expired yet?

Select the correct answer

1

It flushes the entire cache and starts cold to guarantee free memory now exists.

2

It rejects all new writes until some existing key's TTL eventually expires soon.

3

It evicts existing entries based on its configured eviction policy to free space.

4

It spills the overflow entries onto disk automatically without evicting anything.

What happens to a cached resource when a 'Conditional GET' (If-None-Match) returns a 304 Not Modified?

Select the correct answer

1

The cached copy is served and its freshness lifetime is renewed without downloading the body

2

The cached copy is discarded and the full resource is re-downloaded from the origin server

3

The cached copy is served but immediately marked stale, forcing another request next time

4

The cached copy's body is partially updated using the delta returned within the response

How does a sliding TTL differ from a fixed TTL?

Select the correct answer

1

Sliding TTL expires at a fixed wall-clock time, while fixed TTL extends on every read access

2

Sliding TTL applies only to writes, while fixed TTL applies only to read operations of keys

3

Sliding TTL resets the expiry on each access, while fixed TTL expires at a set time after write

4

Sliding TTL guarantees stronger consistency, while fixed TTL allows serving arbitrarily stale data

What is the difference between an In-Process (Local) cache and a Distributed (Remote) cache? When would you choose one over the other?

Select the correct answer

1

In-process persists data to disk for durability; distributed only holds data in volatile memory and loses everything whenever a single node restarts.

2

In-process lives in the app's own memory and is fastest but unshared; distributed runs as a shared service with network cost but consistency.

3

In-process scales horizontally by adding nodes automatically; distributed is limited to one machine's RAM and cannot grow beyond that fixed capacity.

4

In-process is shared across all servers over the network; distributed is private per instance and avoids any serialization or coherence problems entirely.