diff options
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/includes/common.inc b/includes/common.inc index b85c0530e..28086de9b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -473,12 +473,22 @@ function cache_set($cid, $data, $expire = 0) { } } -function cache_del($cid) { - db_query("DELETE FROM cache WHERE cid = '%s'", $cid); +function cache_clear_all($cid = NULL) { + if (empty($cid)) { + db_query("DELETE FROM cache"); + } + else { + db_query("DELETE FROM cache WHERE cid = '%s'", $cid); + } } -function cache_clear() { - db_query("DELETE FROM cache WHERE expire < ". time() ." AND expire > 0"); +function cache_clear_old($cid = NULL) { + if (empty($cid)) { + db_query("DELETE FROM cache WHERE expire < ". time() ." AND expire > 0"); + } + else { + db_query("DELETE FROM cache WHERE cid = '%s' AND expire < %s AND expire > 0", $cid, time()); + } } function page_set_cache() { @@ -486,7 +496,7 @@ function page_set_cache() { if (!$user->uid && $REQUEST_METHOD == "GET") { if ($data = ob_get_contents()) { - cache_set(request_uri(), $data, (time() + variable_get("cache_clear", 30))); + cache_set(request_uri(), $data, (time() + variable_get("cache_clear", 120))); } } } @@ -496,7 +506,7 @@ function page_get_cache() { if (!$user->uid && $REQUEST_METHOD == "GET") { if ($cache = cache_get(request_uri())) { - cache_clear(); + cache_clear_old(); } else { ob_start(); |