Graphics Programs Reference
In-Depth Information
Advanced Caching
The caching mechanism for Apple's top songs feed is pretty simple: each time a new feed
is fetched, it completely replaces the old feed in the cache. This makes sense for this partic-
ular feed - we aren't maintaining a history of top songs, just showing the current top ten.
The Big Nerd Ranch forum feed is a little different. Every time a new feed is fetched, you
are getting the last day's worth of posts. If we cached this feed in the same way as Apple's
feed, we wouldn't be able to maintain a history. Also, the forum feed can be pretty large
since we get a lot of posts in a day, so it takes a few moments to load the feed. It would be
better for the user if they could see a list of cached posts as soon as they open the applica-
tion or switch back to the BNR feed. When new posts become available, they would be ad-
ded to the top of the list.
Figure 29.2 Cache and update flow
We can accomplish this task by implementing caching for the Big Nerd Ranch forum feed
in a different way than we did for the Apple feed. For BNR's feed, each time a controller
requests that the store fetch new items, the store will immediately return the cache and then
ask the server for more items. When the items come back from the server, the store will
merge the new items into its cached RSSChannel . Then, the store will inform the control-
 
Search WWH ::




Custom Search