Async checkpoint
Challenge on lesson: Checkpoint: async
CHALLENGE
Difficulty: advanced+25 XP
Implement static async ValueTask<int> ReadCachedAsync(int key, Func<int, Task<int>> slowFetch): a static ConcurrentDictionary<int,int> cache; on hit return synchronously WITHOUT awaiting (ValueTask fast path); on miss await slowFetch and store the result. Then implement static async Task<string> WithTimeout(Task<string> work, TimeSpan timeout) returning the work's result or throwing TimeoutException โ using CancellationTokenSource with a timeout, and cancelling the linked token.
Press Submit to check your solution.
Back to lesson: Checkpoint: async