Commit d06152e9 authored by merlinofchaos's avatar merlinofchaos
Browse files

#115849: Use dedicated cache table for views caching

parent 02305141
......@@ -113,6 +113,16 @@
KEY (vid)
) /*!40100 DEFAULT CHARACTER SET utf8 */");
db_query("CREATE TABLE {cache_views} (
cid varchar(255) NOT NULL default '',
data longblob,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
$success = TRUE;
break;
case 'pgsql':
......@@ -375,5 +385,15 @@ function views_update_12() {
$ret[] = update_sql("ALTER TABLE {view_view} DROP query");
$ret[] = update_sql("ALTER TABLE {view_view} DROP countquery");
$ret[] = update_sql("CREATE TABLE {cache_views} (
cid varchar(255) NOT NULL default '',
data longblob,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
return $ret;
}
......@@ -63,11 +63,11 @@ function views_menu($may_cache) {
}
}
else {
$data = cache_get("views_with_inline_args:$locale", 'cache');
$data = cache_get("views_with_inline_args:$locale", 'cache_views');
if ($data == 0) {
// There's no cache for our language, regenerate it.
views_reset_inline_args_cache($locale);
$data = cache_get("views_with_inline_args:$locale");
$data = cache_get("views_with_inline_args:$locale", 'cache_views');
}
$views = unserialize($data->data);
......@@ -133,7 +133,7 @@ function views_reset_inline_args_cache($locale = 'en') {
}
}
}
cache_set("views_with_inline_args:$locale", 'cache', serialize($views_with_inline_args));
cache_set("views_with_inline_args:$locale", 'cache_views', serialize($views_with_inline_args));
}
/**
......@@ -682,7 +682,7 @@ function _views_is_cacheable(&$view) {
* Invalidate the views cache, forcing a rebuild on the next grab of table data.
*/
function views_invalidate_cache() {
cache_clear_all('views_', 'cache', true);
cache_clear_all('*', 'cache_views', true);
}
// ---------------------------------------------------------------------------
......@@ -709,7 +709,7 @@ function _views_delete_view($view) {
db_query("DELETE FROM {view_argument} where vid=%d", $view->vid);
db_query("DELETE FROM {view_tablefield} where vid=%d", $view->vid);
cache_clear_all('views_query:' . $view->name, 'cache');
cache_clear_all('views_query:' . $view->name, 'cache_views');
}
/**
......@@ -840,7 +840,7 @@ function _views_save_view($view) {
db_query("DELETE from {view_filter} WHERE vid='$view->vid'");
db_query("DELETE from {view_exposed_filter} WHERE vid='$view->vid'");
cache_clear_all('views_query:' . $view->name, 'cache');
cache_clear_all('views_query:' . $view->name, 'cache_views');
}
else {
// insert
......
......@@ -27,7 +27,7 @@ function _views_get_arguments($titles = false) {
global $locale;
if (!$views_arguments) {
$data = cache_get("views_arguments:$locale", 'cache');
$data = cache_get("views_arguments:$locale", 'cache_views');
$cache = unserialize($data->data);
if (is_array($cache)) {
$views_arguments = $cache;
......@@ -54,7 +54,7 @@ function _views_get_arguments($titles = false) {
$views_arguments['title'][$name] = $arg;
}
$cache = $views_arguments;
cache_set("views_arguments:$locale", 'cache', serialize($cache));
cache_set("views_arguments:$locale", 'cache_views', serialize($cache));
}
}
return ($titles ? $views_arguments['base'] : $views_arguments['title']);
......@@ -69,7 +69,7 @@ function _views_get_tables($full = false) {
global $locale;
if (!$views_tables) {
$data = cache_get("views_tables:$locale", 'cache');
$data = cache_get("views_tables:$locale", 'cache_views');
$cache = unserialize($data->data);
if (is_array($cache)) {
......@@ -141,7 +141,7 @@ function _views_get_tables($full = false) {
}
}
}
cache_set("views_tables:$locale", 'cache', serialize($views_tables));
cache_set("views_tables:$locale", 'cache_views', serialize($views_tables));
}
}
return ($full ? $views_tables : $views_tables['tables']);
......@@ -221,7 +221,7 @@ function _views_get_default_views() {
global $locale;
if (!$views_default_views) {
$data = cache_get("views_default_views:$locale", 'cache');
$data = cache_get("views_default_views:$locale", 'cache_views');
$cache = unserialize($data->data);
if (is_array($cache)) {
......@@ -240,7 +240,7 @@ function _views_get_default_views() {
$views_default_views[$i] = $view;
}
}
cache_set("views_default_views:$locale", 'cache', serialize($views_default_views));
cache_set("views_default_views:$locale", 'cache_views', serialize($views_default_views));
}
}
return $views_default_views;
......@@ -262,7 +262,7 @@ function _views_sort_arrays($a, $b) {
}
function _views_get_query(&$view, $args) {
if ($view->is_cacheable && ($cached = cache_get('views_query:' . $view->name, 'cache'))) {
if ($view->is_cacheable && ($cached = cache_get('views_query:' . $view->name, 'cache_views'))) {
$info = unserialize($cached->data);
$plugins = _views_get_style_plugins();
......@@ -278,7 +278,7 @@ function _views_get_query(&$view, $args) {
'query' => _views_replace_args($info['query'], $info['args']),
'countquery' => _views_replace_args($info['countquery'], $info['args']),
);
cache_set('views_query:' . $view->name, 'cache', serialize($data));
cache_set('views_query:' . $view->name, 'cache_views', serialize($data));
}
}
......@@ -308,7 +308,7 @@ function _views_get_style_plugins($titles = false) {
global $locale;
if (!$views_style_plugins) {
$data = cache_get("views_style_plugins:$locale", 'cache');
$data = cache_get("views_style_plugins:$locale", 'cache_views');
$cache = unserialize($data->data);
if (is_array($cache)) {
$views_style_plugins = $cache;
......@@ -324,7 +324,7 @@ function _views_get_style_plugins($titles = false) {
$views_style_plugins['base'][$name] = $arg;
}
$cache = $views_style_plugins;
cache_set("views_style_plugins:$locale", 'cache', serialize($cache));
cache_set("views_style_plugins:$locale", 'cache_views', serialize($cache));
}
}
return ($titles ? $views_style_plugins['title'] : $views_style_plugins['base']);
......
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