function views_content_cache_id_schema in Views content cache 7.3
Same name and namespace in other branches
- 6.2 views_content_cache.module \views_content_cache_id_schema()
Retrieve or generate the cache id to schema mapping.
We store the schema mapping in the main cache table/bin, this means that it can get invalidated quite quickly, but this will also probably coincide with the views cache being flushed, so we're are just wasting a few CPU cycles in reality.
Parameters
boolean $reset: Reset the static and DB cache for the schema mapping.
Return value
array An array where each key is a plugin key ID and each value is the corresponding database column.
2 calls to views_content_cache_id_schema()
- views_content_cache_and_or_key_get in ./
views_content_cache.module - Determine how this cache segment should be combined with others.
- views_content_cache_id_record in ./
views_content_cache.module - Convert a cache id to an update record suitable for drupal_write_record() or use in a SELECT query.
File
- ./
views_content_cache.module, line 290 - Views content cache cache.
Code
function views_content_cache_id_schema($reset = FALSE) {
static $map;
if (!isset($map) || $reset) {
$cache = cache_get('views_content_cache_id_schema');
if (!$reset && !empty($cache->data)) {
$map = $cache->data;
}
else {
$cache_keys = array_keys(views_content_cache_get_plugin());
$i = 1;
foreach ($cache_keys as $key_id) {
// Schema is limited to 8.
if ($i > 8) {
break;
}
$map[$key_id] = "c{$i}";
$i++;
}
// If the newly generated map and the prior map do not match invalidate
// all cache update records.
if (empty($cache->data) || $map != $cache->data) {
db_truncate('views_content_cache')
->execute();
// This is probably too aggressive. @TODO: See if we can surgically
// invalidate only views that use VCC.
views_invalidate_cache();
}
cache_set('views_content_cache_id_schema', $map, 'cache');
}
}
return $map;
}