Design an in-memory LRU cache for a single machine using a hash map and a doubly linked list to support O(
-
get and put. Explain how you handle capacity, eviction, and key updates. Then make your design thread-safe: discuss lock granularity (global lock vs. per-bucket/segmented locks), readers–writer locks, lock-free alternatives, and how you would prevent race conditions and ensure memory safety. Analyze time and space complexity and outline major pitfalls.