Commit 7130b022 authored by Cody Craven's avatar Cody Craven
Browse files

Issue #1261270 by codycraven: Added caching to fetch taxonomy display settings.

parent 91ead40d
......@@ -2,6 +2,7 @@
Taxonomy Display 7.x-1.x, YYYY-MM-DD
------------------------------------
Issue #1261270 by codycraven: Added caching to fetch taxonomy display settings.
Taxonomy Display 7.x-1.0-rc2, 2011-08-17
--------------------------------------
......
......@@ -50,7 +50,11 @@ function taxonomy_display_delete_taxonomy_dislpay($machine_name, $watchdog_messa
* Return associated array.
*/
function taxonomy_display_fetch_taxonomy_display($machine_name) {
// TODO: Add caching
// Attempt to fetch cached settings for the machine name.
$cache = cache_get('taxonomy_display:settings:' . $machine_name);
if ($cache) {
return $cache->data;
}
$result = db_select('taxonomy_display', 'td')
->fields('td')
......@@ -90,6 +94,9 @@ function taxonomy_display_fetch_taxonomy_display($machine_name) {
}
}
// Store $result for next time.
cache_set('taxonomy_display:settings:' . $machine_name, $result);
return $result;
}
......@@ -160,9 +167,6 @@ function taxonomy_display_permission() {
* returned.
*/
function taxonomy_display_plugins($type = NULL) {
// TODO: Add caching, likely not a big issue as this is only called in admin
// areas, but still.
$plugins = module_invoke_all('taxonomy_display_plugins');
// Expose our retrieved plugins to altering.
......@@ -313,6 +317,13 @@ function taxonomy_display_save_taxonomy_display($machine_name, $save_data = arra
drupal_set_message(t('Taxonomy display data save failed. Message = %message, query= %query',
array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error');
}
// Clear our display settings for the machine name.
cache_clear_all('taxonomy_display:settings:' . $machine_name, 'cache');
// Regenerate the display settings for the machine name in cache so they are
// ready on the next load.
taxonomy_display_fetch_taxonomy_display($machine_name);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment