Caching and Grocery Shopping
I recently talked with @TheJudgeOfCheese (t) about design patterns and grocery shopping.
I Don’t Cache, I Just Drive Fast
Don’t implement a caching tier– go to the database for every query.
Plan to cook a dozen eggs. Go to the grocery store, and on each trip by an egg and a pat of butter. For a while this works if you can drive there really fast. Things get ugly when the store is crowded.
Create a function in your application that runs a query. The query returns a result set with multiple values, but the function returns only one value at any given time.
Call the function individually for each value in the result set.
Create a shopping list with 10 items. Go to the store and purchase all ten items and put them in the car and drive them home. When you get home, take one item out of the car. Throw the other nine items away. Repeat for each additional item.