diff options
author | Dries Buytaert <dries@buytaert.net> | 2002-11-17 06:42:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2002-11-17 06:42:52 +0000 |
commit | 9e32c2e9606079e72c58075d9167634dcfc65a01 (patch) | |
tree | ba24bf55130fcc3ec59562b35b764bc9e73d4e8e /includes | |
parent | 64f8781f789912751849c506a9a412ed27ddd0db (diff) | |
download | brdo-9e32c2e9606079e72c58075d9167634dcfc65a01.tar.gz brdo-9e32c2e9606079e72c58075d9167634dcfc65a01.tar.bz2 |
Patch based on work of Kjartan:
- Changed cache API.
- Fixed caching bug in comment.module. Odd this hasn't been reported yet.
- Fixed caching bug in forum.module.
- Fixed caching bug in system.module.
- Fixed caching bug in block.module.
- Simplified caching support in forum.module thanks to improved cache API.
Diffstat (limited to 'includes')
-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(); |