As you might guess, since each class is hiding all of the internal processing behind its interface, coding an example to demonstrate the caching system’s functionality is a breeze. The lines below show a simple way of caching result sets: // include the class files (notice that class files can be try { As you can see, the example speaks for itself. To demonstrate the functionality of the caching system, I’ve explicitly used the available methods for fetching result sets. Doing so, the usage of them is clearly demonstrated, in this case by displaying the data from a “users” database table. However, it’s feasible to use one method for data visualization and another for different processing (i.e. sending by email cached data). Another possibility would be to use the “fetchRange()” method for displaying paginated data. As usual, feel free to add your own application for each explained method. Once the required functionality is available, possibilities are really numerous. Conclusion Finally, the journey has ended. Through this series, we’ve explored together the many options that PHP offers for caching result sets. Starting out from the creation of a simple procedural script, to the development of a more advanced object-oriented solution, hopefully the whole experience has been rich both in theory and practice. Result set caching is a powerful technique that can be implemented to accelerate many websites that deliver quite static content, and PHP exposes a set of nice features to take advantage of caching solutions. Reduced server overload and limited query execution translate directly into faster and more efficient web applications. From a developer’s point of view, there is much to gain in terms of better performance and cost-efficient website acceleration.
blog comments powered by Disqus |