Battletech Live

Online, Turn-Based Battletech – Development Logs

The importance of caching query results.

Recently, I have begun building the structure and logic for the Technical Readouts, located on the Expanded Universe tab of Battletech Live.  It’s set up so that when you open the Technical Readouts panel and select a book, the system accesses the database and retrieves an XML list for the table of contents and an ID used to represent the book cover.  The table of contents is divided into chapters, which can be browsed to select individual pieces of equipment or units.  When that selection is made, it connects to the server and (so far) retrieves seven pieces of information:  book, name, mass, manufacturer, picture, year, description and type.  Moving from book entry to book entry can be fairly intensive, which I learned last night.  At one point, I apparently spiked the CPU utilization of the web server over 60% and caused an automatic suspension.  It only banned me for 60 seconds, but it was enough of a warning that I needed to start putting caching in place.  I didn’t do this during the build-up phase of the Technical Readouts.

Now, when you select an individual technical readout, it checks a local arrayCollection for the information.  If the information isn’t found, it then sends the query to the server and writes the results to the array.  In this way, each individual element need only be retrieved once.  At present, the arrayCollection is flushed when the webpage is refreshed so I’m working on methods to save the retrieved data to a Shared Object along with a timestamp.  When data is retrieved from the server, it will save it as a Shared Object on the computer along with the timestamp.  The next time the page is loaded, it will check the Shared Object.  If not found, it will retrieve from the server.  If it is found, it will compare the timestamp of the Shared Object with a corresponding record on the server and if they don’t match, it will pull new data.

picture-2

Advertisements

April 16, 2009 - Posted by | Project Development

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: