|
OpenSencillo
2015.002
|
Go to the source code of this file.
Functions | |
| quickcache_db_connect () | |
| quickcache_db_disconnect () | |
| quickcache_db_query ($query) | |
| quickcache_restore () | |
| quickcache_write ($gzdata, $datasize, $datacrc) | |
| quickcache_do_gc () | |
| quickcache_do_start () | |
| quickcache_do_end () | |
| quickcache_db_query | ( | $ | query | ) |
Definition at line 151 of file mysql.php.
{
// Disconnect from db
quickcache_db_disconnect();
}
| quickcache_do_gc | ( | ) |
Definition at line 124 of file mysql.php.
{
quickcache_db_query("delete from ".
$GLOBALS["QUICKCACHE_DB_TABLE"].
" where CACHEEXPIRATION<=".
time().
" and CACHEEXPIRATION!=0"
);
// Are we allowed to do an optimize table-call?
// As noted, first check if this works on your mysql-installation!
if ($GLOBALS["QUICKCACHE_OPTIMIZE"]) {
quickcache_db_query("OPTIMIZE TABLE ".$GLOBALS["QUICKCACHE_DB_TABLE"]);
}
}
Definition at line 142 of file mysql.php.
{
// Connect to db
quickcache_db_connect();
}
Definition at line 49 of file mysql.php.
{
$res = quickcache_db_query("select GZDATA, DATASIZE, DATACRC from ".
$GLOBALS["QUICKCACHE_DB_TABLE"].
" where CACHEKEY='".
addslashes($GLOBALS["quickcache_key"]).
"' and (CACHEEXPIRATION>".
time().
" or CACHEEXPIRATION=0)"
);
if ($res && mysql_num_rows($res))
{
if ($row = mysql_fetch_array($res))
{
// restore data into global scope from found row
$GLOBALS["quickcachedata_gzdata"] = $row["GZDATA"];
$GLOBALS["quickcachedata_datasize"] = $row["DATASIZE"];
$GLOBALS["quickcachedata_datacrc"] = $row["DATACRC"];
return true;
}
}
return false;
}
| quickcache_write | ( | $ | gzdata, |
| $ | datasize, | ||
| $ | datacrc | ||
| ) |
Definition at line 76 of file mysql.php.
{
$dbtable = $GLOBALS["QUICKCACHE_DB_TABLE"];
// XXX: Later on, maybe implement locking mechanism inhere.
// Check if it already exists
$res = quickcache_db_query("select CACHEEXPIRATION from $dbtable".
" where CACHEKEY='".
addslashes($GLOBALS["quickcache_key"]).
"'"
);
if (!$res || mysql_num_rows($res) < 1) {
// Key not found, so insert
$res = quickcache_db_query("insert into $dbtable".
" (CACHEKEY, CACHEEXPIRATION, GZDATA,".
" DATASIZE, DATACRC) values ('".
addslashes($GLOBALS["quickcache_key"]).
"',".
(($GLOBALS["QUICKCACHE_TIME"] != 0) ?
(time()+$GLOBALS["QUICKCACHE_TIME"]) : 0).
",'".
addslashes($gzdata).
"', $datasize, $datacrc)"
);
// This fails with unique-key violation when another thread has just
// inserted the same key. Just continue, as the result is (almost)
// the same.
} else {
// Key found, so update
$res = quickcache_db_query("update $dbtable set CACHEEXPIRATION=".
(($GLOBALS["QUICKCACHE_TIME"] != 0) ?
(time()+$GLOBALS["QUICKCACHE_TIME"]) : 0).
", GZDATA='".
addslashes($gzdata).
"', DATASIZE=$datasize, DATACRC=$datacrc where".
" CACHEKEY='".
addslashes($GLOBALS["quickcache_key"]).
"'"
);
// This might be an update too much, but it shouldn't matter
}
}