This module implements various hooks to react to changes to other modules' data: hook_node_insert(), hook_comment_insert(), hook_votingapi_results(), etc.
All of these hook implementations call views_content_cache_update_set() with the object that has just been updated, and a string representing the type of object (node, comment, etc).
views_content_cache_update_set() then calls to get a cache ID from the object that has just been updated.
It does this by loading all the plugins, and calling content_key() on each one.
In content_key(), each plugin class figures out whether it it relevant to the current object, and if so, returns a cache ID.
The bit that causes me concern is where views_content_cache_id_generate() loads every VCC plugin, regardless of whether it's needed or not by the current operation. This is quite a lot of work, especially as there are lots of issues in the queue to add support for more contrib modules (#1185268: Nodequeue support (plugin), #1282056: Flag support (plugin)).
I am wondering whether it would be better -- and worth the work in changing it -- if the module only loaded the plugins that were relevant to the current object. This is easier said than done, as several plugins react to nodes -- views_content_cache_key_og and views_content_cache_key_comment for instance.
But I think there's a way to do this: CTools caches plugin *definitions*. When you call
$plugins = ctools_get_plugins('views_content_cache', 'plugins');
you're getting cached data (or you should be!).
Hence, hook_views_content_cache_plugins() could have an extra property, say, 'object_types', which would look like this:
$plugins['node'] = array(
'title' => t('Node type'),
'description' => t('Invalidates cache by node type'),
'object_types' => array(
'node' => TRUE,
'comment' => TRUE,
),
'handler' => array(
'path' => drupal_get_path('module', 'views_content_cache') . '/plugins',
'file' => 'node.inc',
'class' => 'views_content_cache_key_node',
'parent' => 'base',
),
);
This means that views_content_cache_id_generate() needs to first get the plugin definitions from CTools, loop through them doing:
if (isset($plugin_info['object_types'][$object_type])) {
// Add this plugin to the list we need to work with.
}
The other thing is you'd need to change views_content_cache_get_plugin() to lazy-load only the plugins you're asking for each time.
Like I say, I am not sure of how much of an improvement this would be -- but posting this to have the idea discussed at least :)