This project will serve many duplicate requests with location-specific answers. I.e. 10,000 people in New York will all get the same server response (a list of businesses in New York), but one person in Atlanta will get completely different data (businesses in Atlanta).
1. In memory cache which stores the most recent answer for each location. Answers expire every few minutes and an updated answer from the database is loaded.
2. Relational Database stores all the actual business data to make answers.
How can I group cache results by location?
1. Each database row could know which city the business is in, and users would need to pick their city from a list. Then I would have a separate result cache for each city.
2. I could just take the user's lat/long and store the lat/long of every business in the database row and do a location query. I do not know how much cacheing I could do with that approach. Maybe see if I've answered a request within 20 miles of the query location, re-use that response? This avoids having to group things ahead of time but is less accurate.
This seems like a common problem. Is one of these approaches preferred (or something different altogether)? The table in question will have ~100k records worst case, so is this cacheing overkill anyway? Planning to use AWS if that changes anything, or if they have tools for this I should be aware of.