Project2.3 Advanced Scaling Concepts: Caching
Goal: Explain and implement cache.
- Temporal locality: set caceh TTL
- 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:1234567891011else { 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?