
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
You can delay execution of code with "ref = setTimeout(fn, delay)". You can abort the execution with "clearTimeout(ref)"
When storing the values in the cache, also store a reference to the timeout. The timeout should clear the key from the cache after the expiration has elapsed.
When you set a key that already exists, clear the existing timeout.