15619 Project2.3 Guide

Project2.3 Advanced Scaling Concepts: Caching

Goal: Explain and implement cache.

  1. Temporal locality: set caceh TTL
  2. Spatial locality: get a batch of data which are likely to be accessed together

In this project, we will create a simple cache using HashMap. Some suggested that we should use LinkedHashMap, why? As I tried, I didn’t see any improvement in performance. We suppose to apply a sophisticated strategy, however I end up with this simple strategy:

1
2
3
4
5
6
7
8
9
10
11
else {
int start = targetInt - 30;
int end = targetInt + 49;
// Update most recent ID
mostRecentID = targetInt;
// Return the response of target ID
return storeRangeIntoMap(start, end, targetInt);
}

I tried to distinguish decrease and increase but didn’t see any improvement neither. Is there a better way to do this?