0
0
HLDsystem_design~10 mins

Multi-level caching in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the first level cache type.

HLD
cache = [1]Cache()  # First level cache for fastest access
Drag options to blanks, or click blank then click option'
ADatabase
BDisk
CInMemory
DNetwork
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing disk or database for first level cache.
2fill in blank
medium

Complete the code to define the second level cache type.

HLD
cache = [1]Cache()  # Second level cache for larger but slower storage
Drag options to blanks, or click blank then click option'
AGPU
BInMemory
CCPU
DDisk
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing in-memory cache again or hardware components.
3fill in blank
hard

Fix the error in the cache eviction policy assignment.

HLD
cache.eviction_policy = '[1]'  # Set eviction policy to remove least recently used items
Drag options to blanks, or click blank then click option'
ARandom
BLRU
CFIFO
DMRU
Attempts:
3 left
💡 Hint
Common Mistakes
Using FIFO or MRU which do not fit typical cache eviction.
4fill in blank
hard

Fill both blanks to complete the multi-level cache lookup logic.

HLD
if [1] in L1_cache:
    return L1_cache[[2]]
Drag options to blanks, or click blank then click option'
Akey
Bvalue
Ccache
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' or 'item' which are not keys for lookup.
5fill in blank
hard

Fill all three blanks to complete the cache update after a miss.

HLD
if key not in L1_cache:
    data = [1].get(key)
    L2_cache.[2](key, data)
    L1_cache.[3](key, data)
Drag options to blanks, or click blank then click option'
Adatabase
Bput
Cset
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using fetch as a method on cache or wrong data source.