aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/database.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2013-04-13 14:10:02 -0400
committercash <cash.costello@gmail.com>2013-04-13 14:10:02 -0400
commit726007e5730f83340ea8ab294a9f5951586f42fc (patch)
tree0843506c2e7e1840a08dc9bf0a05dfeba9f6659e /engine/lib/database.php
parent5dd3d179f43b47231dab5dab5d5d9482a9810ef7 (diff)
downloadelgg-726007e5730f83340ea8ab294a9f5951586f42fc.tar.gz
elgg-726007e5730f83340ea8ab294a9f5951586f42fc.tar.bz2
introduces _elgg_invalidate_query_cache() to dry up the db query cache code
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r--engine/lib/database.php38
1 files changed, 16 insertions, 22 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 18235149d..b41eb4cda 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -460,19 +460,12 @@ function elgg_query_runner($query, $callback = null, $single = false) {
* @access private
*/
function insert_data($query) {
- global $DB_QUERY_CACHE;
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
- // Invalidate query cache
- if ($DB_QUERY_CACHE) {
- /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
- $DB_QUERY_CACHE->clear();
- }
-
- elgg_log("Query cache invalidated", 'NOTICE');
+ _elgg_invalidate_query_cache();
if (execute_query("$query", $dblink)) {
return mysql_insert_id($dblink);
@@ -492,18 +485,12 @@ function insert_data($query) {
* @access private
*/
function update_data($query) {
- global $DB_QUERY_CACHE;
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
- // Invalidate query cache
- if ($DB_QUERY_CACHE) {
- /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
- $DB_QUERY_CACHE->clear();
- elgg_log("Query cache invalidated", 'NOTICE');
- }
+ _elgg_invalidate_query_cache();
if (execute_query("$query", $dblink)) {
return TRUE;
@@ -523,18 +510,12 @@ function update_data($query) {
* @access private
*/
function delete_data($query) {
- global $DB_QUERY_CACHE;
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
- // Invalidate query cache
- if ($DB_QUERY_CACHE) {
- /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
- $DB_QUERY_CACHE->clear();
- elgg_log("Query cache invalidated", 'NOTICE');
- }
+ _elgg_invalidate_query_cache();
if (execute_query("$query", $dblink)) {
return mysql_affected_rows($dblink);
@@ -543,6 +524,19 @@ function delete_data($query) {
return FALSE;
}
+/**
+ * Invalidate the query cache
+ *
+ * @access private
+ */
+function _elgg_invalidate_query_cache() {
+ global $DB_QUERY_CACHE;
+ if ($DB_QUERY_CACHE) {
+ /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+ }
+}
/**
* Return tables matching the database prefix {@link $CONFIG->dbprefix}% in the currently