tracing instead of cache debug log
This commit is contained in:
parent
bca74a0db5
commit
c8563951ce
2 changed files with 10 additions and 14 deletions
|
@ -188,14 +188,11 @@ class Cache
|
||||||
|
|
||||||
public function get(string $key)
|
public function get(string $key)
|
||||||
{
|
{
|
||||||
global $_tracer;
|
global $_tracer;
|
||||||
$_tracer->begin("Cache Query", ["key"=>$key]);
|
$_tracer->begin("Cache Query", ["key"=>$key]);
|
||||||
$val = $this->engine->get($key);
|
$val = $this->engine->get($key);
|
||||||
if ((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
$hit = $val === false ? "hit" : "miss";
|
||||||
$hit = $val === false ? "hit" : "miss";
|
$_tracer->end(null, ["result"=>$hit]);
|
||||||
file_put_contents("data/cache.log", "Cache $hit: $key\n", FILE_APPEND);
|
|
||||||
}
|
|
||||||
$_tracer->end();
|
|
||||||
if ($val !== false) {
|
if ($val !== false) {
|
||||||
$this->hits++;
|
$this->hits++;
|
||||||
return $val;
|
return $val;
|
||||||
|
@ -207,18 +204,18 @@ class Cache
|
||||||
|
|
||||||
public function set(string $key, $val, int $time=0)
|
public function set(string $key, $val, int $time=0)
|
||||||
{
|
{
|
||||||
|
global $_tracer;
|
||||||
|
$_tracer->begin("Cache Set", ["key"=>$key, "time"=>$time]);
|
||||||
$this->engine->set($key, $val, $time);
|
$this->engine->set($key, $val, $time);
|
||||||
if ((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
$_tracer->end();
|
||||||
file_put_contents("data/cache.log", "Cache set: $key ($time)\n", FILE_APPEND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(string $key)
|
public function delete(string $key)
|
||||||
{
|
{
|
||||||
|
global $_tracer;
|
||||||
|
$_tracer->begin("Cache Delete", ["key"=>$key]);
|
||||||
$this->engine->delete($key);
|
$this->engine->delete($key);
|
||||||
if ((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
$_tracer->end();
|
||||||
file_put_contents("data/cache.log", "Cache delete: $key\n", FILE_APPEND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_hits(): int
|
public function get_hits(): int
|
||||||
|
|
|
@ -30,7 +30,6 @@ _d("DATABASE_KA", true); // string Keep database connection alive
|
||||||
_d("DATABASE_TIMEOUT", 10000);// int Time to wait for each statement to complete
|
_d("DATABASE_TIMEOUT", 10000);// int Time to wait for each statement to complete
|
||||||
_d("CACHE_DSN", null); // string cache connection details
|
_d("CACHE_DSN", null); // string cache connection details
|
||||||
_d("DEBUG", false); // boolean print various debugging details
|
_d("DEBUG", false); // boolean print various debugging details
|
||||||
_d("DEBUG_CACHE", false); // boolean dump cache queries to data/cache.log
|
|
||||||
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
||||||
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
||||||
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
||||||
|
|
Reference in a new issue