Doing negative caching for config values, special logfile for database optmisations

This commit is contained in:
Michael Vogel 2012-05-26 15:41:23 +02:00
parent a5dc41ab13
commit 7f19d39b14
2 changed files with 26 additions and 4 deletions

View file

@ -30,6 +30,9 @@ function load_config($family) {
$a->config[$family][$k] = $rr['v']; $a->config[$family][$k] = $rr['v'];
} }
} }
} else if ($rr['cat'] != 'config') {
// Negative caching
$a->config[$family] = "!<unset>!";
} }
}} }}
@ -47,6 +50,13 @@ function get_config($family, $key, $instore = false) {
global $a; global $a;
if(! $instore) { if(! $instore) {
// Looking if the whole family isn't set
if(isset($a->config[$family])) {
if($a->config[$family] === '!<unset>!') {
return false;
}
}
if(isset($a->config[$family][$key])) { if(isset($a->config[$family][$key])) {
if($a->config[$family][$key] === '!<unset>!') { if($a->config[$family][$key] === '!<unset>!') {
return false; return false;
@ -118,6 +128,9 @@ function load_pconfig($uid,$family) {
$k = $rr['k']; $k = $rr['k'];
$a->config[$uid][$family][$k] = $rr['v']; $a->config[$uid][$family][$k] = $rr['v'];
} }
} else if ($rr['cat'] != 'config') {
// Negative caching
$a->config[$uid][$family] = "!<unset>!";
} }
}} }}
@ -129,6 +142,13 @@ function get_pconfig($uid,$family, $key, $instore = false) {
global $a; global $a;
if(! $instore) { if(! $instore) {
// Looking if the whole family isn't set
if(isset($a->config[$uid][$family])) {
if($a->config[$uid][$family] === '!<unset>!') {
return false;
}
}
if(isset($a->config[$uid][$family][$key])) { if(isset($a->config[$uid][$family][$key])) {
if($a->config[$uid][$family][$key] === '!<unset>!') { if($a->config[$uid][$family][$key] === '!<unset>!') {
return false; return false;

View file

@ -77,14 +77,16 @@ class dba {
$this->error = ''; $this->error = '';
//@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); if (get_config("system", "db_log") != "")
@file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND);
if($this->mysqli) if($this->mysqli)
$result = @$this->db->query($sql); $result = @$this->db->query($sql);
else else
$result = @mysql_query($sql,$this->db); $result = @mysql_query($sql,$this->db);
//@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); if (get_config("system", "db_log") != "")
@file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND);
if($this->mysqli) { if($this->mysqli) {
if($this->db->errno) if($this->db->errno)