Complete the code to define the caching policy that writes data to both cache and main storage immediately.
if cache_policy == [1]: write_to_cache(data) write_to_storage(data)
Write-through caching writes data to both cache and main storage immediately to keep them consistent.
Complete the code to define the caching policy that writes data only to cache first and delays writing to storage.
if cache_policy == [1]: write_to_cache(data) mark_dirty(data)
Write-back caching writes data to cache first and delays writing to storage until necessary.
Fix the error in the code to correctly mark data as dirty only in write-back caching.
if cache_policy == 'write-through': write_to_cache(data) [1](data)
In write-through caching, data is written immediately to storage, so marking dirty is not needed.
Fill both blanks to complete the code that flushes dirty data from cache to storage and clears the dirty flag.
if data_is_dirty: [1](data) [2](data)
Dirty data must be written back to storage and then the dirty flag cleared.
Fill all three blanks to complete the code that updates cache and handles write-back caching correctly.
if cache_policy == [1]: write_to_cache(data) [2](data) else: write_to_cache(data) [3](data)
For write-back, data is cached and marked dirty; for write-through, data is cached and written immediately to storage.