An creative use of Drupal 7’s caching system.


First of all, I highly recommend Lullabot’s tutorial on Drupal 7’s caching system.


I have a client who has a large amount of data and calculations that need to be display rapidly for an online bluebook of aircraft. Too big and too complicated for views. Caching is of course an ideal use in this case, combined with a custom module displaying the cache data.


A custom module that displays the data in a custom form using ajax. A custom cache table that uses drupal’s caching system. And pattern the CID of the caching with the ID of the aircraft, allowing the client to clear the cache for just that aircraft without having to rebuild the entire >5000 rows of data. And finally, a simple form for the client to use to clear cache they want.



This client has a second database of 40 years of historical aircraft data. This includes a lot of specification data, data to be graph, pricing tables, etc. The first step was creating a custom cache table using hook_schema. This was because there are occasions that the client will want to do a massive update to its data and needs all cache to be clear. Such as when one manufacturer is brought by another and all their models need to be updated to reflect this change.  Generally, it takes about five minutes to rebuild the entire table. When the cache is being built, there are calculations that is run on the data before it is cache.


The bluebook is built with tabs for each section. The data on each tab is retuned via ajax, allowing for an seamless experience on the user’s end. For graphing, we used Google Charts to render the graphs themselves. This meant to we include dropdown so that the end user could look at data by model year, or limit the graph between two dates. The data itself is formatted to be used by google charts before it is cache.


Finally, the CID of the cache is structure as “${'model_'.$id.'_data_type'}”. Then a custom form was setup, that when the admin clicks “clear aircraft data” for aircraft with a ID of 1, it deletes all rows on the custom cache table that have CID like “model_1%”. This means the cache of that just that model is cleared, and rebuild quickly, leaving the other 200+ models still in place.