This question evaluates system design and algorithmic competencies in bounded storage management, specifically prioritized eviction, recency-aware ordering, per-file and global capacity accounting, and choosing data structures that meet stated complexity targets.
You are designing an in-memory (or on-disk) log storage component. Each inserted log belongs to a file (fileId) and has a priority and a timestamp. Storage is bounded by a global capacity and optional per-file capacities. When capacity is exceeded, the system must automatically evict the "least important" logs first. Importance is defined by priority (higher = more important) and recency (newer = more important).
total_max
.
addLog(fileId, record, priority, timestamp)
must automatically evict when limits are exceeded.
limit[fileId] = X
) and a global limit
total_max
.
Describe your data model, data structures, eviction policy, algorithms, and trade-offs that meet the above requirements and complexities.
Login required