Skip to content
Snippets Groups Projects
Commit ca90577d authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

Backport of #227228 by andypost, et al. Per-table cache_flush variables to...

Backport of #227228 by andypost, et al. Per-table cache_flush variables to avoid not flushing all but the first table when multiple tables are cleared.
parent c8c5f09e
No related merge requests found
......@@ -14,10 +14,10 @@ function cache_get($key, $table = 'cache') {
global $user;
// Garbage collection necessary when enforcing a minimum cache lifetime
$cache_flush = variable_get('cache_flush', 0);
$cache_flush = variable_get('cache_flush_'. $table, 0);
if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
// Reset the variable immediately to prevent a meltdown in heavy load situations.
variable_set('cache_flush', 0);
variable_set('cache_flush_'. $table, 0);
// Time to flush old cache data
db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
}
......@@ -134,16 +134,16 @@ function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
// cached data that was cached before the timestamp.
$user->cache = time();
$cache_flush = variable_get('cache_flush', 0);
$cache_flush = variable_get('cache_flush_'. $table, 0);
if ($cache_flush == 0) {
// This is the first request to clear the cache, start a timer.
variable_set('cache_flush', time());
variable_set('cache_flush_'. $table, time());
}
else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
// Clear the cache for everyone, cache_flush_delay seconds have
// Clear the cache for everyone, cache_lifetime seconds have
// passed since the first request to clear the cache.
db_query("DELETE FROM {". $table. "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
variable_set('cache_flush', 0);
variable_set('cache_flush_'. $table, 0);
}
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment