← 返回 databricks 的题目列表Design Key Value Class with Average Operations
类型:online_judge
Design a Key-Value class that implements the following four methods:
put(string key, string value): Store a key-value pair.
get(string key): Retrieve the value associated with a given key.
averagePut(): Calculate the average number of put method calls in the past five minutes.
averageGet(): Calculate the average number of get method calls in the past five minutes.
Implementation Requirements: Consider high concurrency scenarios and ensure thread safety. Provide detailed function specifications, including input, output, and edge cases. Include thorough test cases to validate the functionality of the methods, considering edge cases and exceptions.
Example
Input
put('a', '1')
put('b', '2')
get('a')
averagePut()
averageGet()