Interview practice question
Corrupted in-memory cache
Backend Engineering · Concurrency · Beginner
Your service uses a plain HashMap as an in-memory cache shared by request threads, and you see strange errors and corrupted data. Why?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- HashMap is not thread-safe.
- Concurrent writes corrupt internals.
- Use ConcurrentHashMap or synchronized access.
- Or a proper cache library (Caffeine).
- Avoid shared mutable structures.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.