Data Caching

Using the DAO layer involves instantiating objects and filling them with data to be consumed by the application. When instances of these objects exist, they can be persisted in memory, on a middle tier or somewhere else. In this way, data access not only is efficient but can be centralized, localized, and distributed. The general aim is to make data quickly available to the parts of the application that need it, without hitting the database more often than necessary.

Take, for instance, a multiplayer networked game, which needs to provide a lot of data to a lot of people. Naturally, most of the data being sent to each user is the same for every user, because the data likely describes the environment in which every player is immersed. Given this example, assuming a sizeable number of users exist, it would not then be efficient for every client to send a request to the database for the same data; the database should be accessed only when necessary. When the application needs data, it should check the cache before going to the database. The cache might consist of the DAO instances stored in java.util.Collection objects. The DAO objects in cache can then perhaps be updated regularly, as needed, or in response to the database tables being updated. The cached data objects could potentially be managed in a variety of ways and deployed anywhere.

At least one game company, Galactic Village Games, has implemented its own homegrown DAO system, which provides all the advantages mentioned previously. In addition to gaining the performance that caching provides, that company has also been able to deploy to at least five runtime database systems with minimal effort by making good use of the DAO pattern.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net