Design and implement a versioned key-value store that supports set(key, value, timestamp) and get(key, timestamp) to retrieve the most recent value at or before timestamp. Discuss data structures, time/space complexity, and how to handle out-of-order timestamps, large timestamp ranges, and memory limits. Extend the API to support delete, range queries by time, and background compaction.