← 返回 databricks 的题目列表KV Store with Sliding-Window Average Latency
类型:online_judge
Implement an in-memory KV store with the following operations:
put(key, value): insert or overwrite a key-value pair and record the operation latency.
get(key): return the value for a key (or null if absent) and record the operation latency.
averageGet(window): return the average latency of all get operations within the past window.
averagePut(window): return the average latency of all put operations within the past window.
The window may be the past hour, day, or week. Expired operations must not affect the result. Design the data structures so that reads, writes, and metric queries remain efficient under high request volume.
Describe and implement the thread-safe core logic.