This implementation provides a dynamic multilevel caching system with LRU and LFU eviction policies, enabling efficient data management across multiple levels.
Design and implement a dynamic multilevel caching system that efficiently manages data across multiple cache levels.
- Supports multiple cache levels (L1, L2, etc.) with different sizes and eviction policies.
- Implements Least Recently Used (LRU) and Least Frequently Used (LFU) eviction policies.
- Dynamic addition and removal of cache levels at runtime.
- Retrieves data across cache levels, promoting it to higher levels when found in lower levels.
- Thread-safe implementation (concurrency is considered).
- Compile the Java files in the
com.midhin.dev.capxbackend.DynamicMultilevelCachingSystem
directory. - Run the
Main
class to see sample operations.
CacheSystem cacheSystem = new CacheSystem();
cacheSystem.addCacheLevel(3, "LRU");
cacheSystem.addCacheLevel(2, "LFU");
cacheSystem.put("A", "1");
cacheSystem.get("A"); // Returns "1" from L1
cacheSystem.put("D", "4"); // Evicts LRU
cacheSystem.displayCache(); // Displays the current state of each cache level.