Test your understanding of cache invalidation strategies with these easy questions. This quiz covers basic concepts and common methods used for keeping cached data accurate and up-to-date in computing environments.
Which cache invalidation strategy removes data after a set time, even if the data hasn't changed?
Explanation: Time-to-Live (TTL) assigns a specific expiry time to cached data, causing it to be invalidated whether or not the original data changes. Manual Refresh requires a specific trigger to update the cache, not time-based removal. Write-through updates the cache immediately when data is written but isn't a time-based invalidation method. LRU is an eviction policy based on usage, not time.
When a database record changes and the related cache entry is immediately removed, which invalidation strategy is being used?
Explanation: Write-invalidate ensures that when underlying data changes, the related cache entries are instantly invalidated. Time-Stamp Policy involves comparing times rather than event-driven removal. Pre-fetching refers to loading data in advance, not invalidation. Cache Partitioning divides cache, not handles updates caused by data changes.
Which invalidation challenge is most common when both client-side and server-side caches are used?
Explanation: Using both client-side and server-side caches can result in inconsistent data because updates may reach caches at different times. Improved bandwidth usage is generally a benefit, not a problem. Reduced cache hit ratio or enhanced privacy are not typical challenges in this context.
If a developer writes a script to clear cached search results every hour, what invalidation strategy is this?
Explanation: Manual Invalidation is performed by explicit developer actions, such as running a script. Cache Coherency deals with maintaining multiple copies. Adaptive Expiry changes expiry dynamically but is automated. Lazy Loading is about populating the cache when data is requested, not invalidation.
In a read-through cache, what happens when a requested item is missing or expired?
Explanation: With read-through caching, missing or expired items cause the system to fetch data from the original source and update the cache. Returning errors, flushing all cache entries, or discarding data permanently are incorrect behaviors and not related to this caching approach.
Which strategy allows cache updates but writes changes to the original data source only after the cache entry is removed or expires?
Explanation: Write-back updates the cache immediately, but only writes changes to the main data upon cache eviction or expiry. Write-invalidate removes stale entries but doesn't delay writes. Read-aside requires the application to manage cache population. Push invalidation informs clients of changes but doesn't relate to delayed writes.
What is a common technique to prevent multiple clients from refreshing the same cache entry at once when it expires (a cache stampede)?
Explanation: Locking or Single-Flight allows only one client to rebuild the cache, preventing all from hitting the data source simultaneously. Randomized Delay can help, but is less direct. Immediate Invalidity or Synchronous Renewal aren't standard terms used for preventing cache stampedes.
What is a possible issue when invalidating cache on updates to a shared data segment accessed by unrelated users (false sharing)?
Explanation: False sharing causes the cache to invalidate even when updates are irrelevant to some users, leading to unnecessary invalidations. Corrupted data transmission is not directly related. Increased cache hit rates and simplified coherence are incorrect, as false sharing generally complicates caching.
When is a cache entry invalidated in a lazy invalidation strategy?
Explanation: Lazy invalidation waits until a request is made and then checks if the data is valid, only invalidating it if outdated. Fixed intervals describe time-based strategies. Automatic invalidation upon any data change is an eager approach. Invalidating before any request is made doesn't align with lazy strategies.
What is the main mechanism of a push invalidation strategy?
Explanation: Push invalidation uses the source to send notifications or messages to caches, ensuring timely invalidation. Polling involves regular checking, not direct notification. Manual user refresh is not automated. Waiting for natural expiry is a passive strategy, not a push approach.