← 返回 linkedin 的题目列表Rank-based Cache with Concurrency
类型:online_judge
You need to design a Rank-based Cache module where the rank of cache entries can change dynamically. Consider the following questions:
How would you handle concurrency issues in a multi-threaded environment? Specify where locks are needed in the code.
How would you handle if the rank from the data source changes rapidly?
If the rank is based on the last access time of the entry, how would you implement this? Provide code examples and test cases.
Example
Input
1
put user1 data1 1
get user1
put user2 data2 2
update_ranks