← 返回 oracle 的题目列表Design a Cache
类型:online_judge
Implement a database cache system in Python. The cache system should have a fixed size and evict old data based on a strategy (LRU, LFU, or FIFO) when it reaches capacity. The cache should support operations such as put, get, and delete. Each operation should complete in constant time. The data limit is 1000 entries. Provide at least three input-output pairs for each operation to test the implementation's correctness.
Example
Input
cache = LRUCache(3)
cache.put(1, 1)
cache.put(2, 2)
cache.put(3, 3)
cache.put(4, 4)
print(cache.get(4))
print(cache.get(3))
print(cache.get(2))
print(cache.get(1))