track response size in stats
This commit is contained in:
parent
ce984610a7
commit
e9febc25c2
13
Cache.php
13
Cache.php
|
@ -98,6 +98,19 @@ class Cache {
|
|||
return $cache;
|
||||
}
|
||||
|
||||
public function size($key, $expiration = 3600) {
|
||||
if ( !is_dir($this->dir) OR !is_writable($this->dir)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name($key);
|
||||
|
||||
if (!@file_exists($cache_path)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return filesize($cache_path);
|
||||
}
|
||||
|
||||
private function mkdir_p($path) {
|
||||
if (!is_dir($path)) {
|
||||
|
|
|
@ -62,9 +62,6 @@ class GopherGetter {
|
|||
$this->errno = "";
|
||||
|
||||
|
||||
$this->logTraffic($this->host, $this->path);
|
||||
|
||||
|
||||
$this->result = $this->cache->get($this->key);
|
||||
if ( $this->result === FALSE ) {
|
||||
error_log("tcp://$this->host:$this->port\t$this->input");
|
||||
|
@ -91,9 +88,14 @@ class GopherGetter {
|
|||
$this->cache->set($this->key, $this->result);
|
||||
}
|
||||
|
||||
$this->logTraffic($this->host, $this->path);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function size() {
|
||||
return $this->cache->size($this->key);
|
||||
}
|
||||
|
||||
function logTraffic($host, $selector) {
|
||||
/* error_log(LOG_STATS);
|
||||
if ( ! isset(LOG_STATS) || LOG_STATS != true ) {
|
||||
|
@ -106,15 +108,12 @@ class GopherGetter {
|
|||
'hostname' => $host,
|
||||
'selector' => $selector,
|
||||
'remote_ip' => $ip_address,
|
||||
'filesize' => $this->size(),
|
||||
'request_at' => DB::sqleval("NOW()")
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
function size() {
|
||||
return strlen($this->result);
|
||||
}
|
||||
|
||||
};
|
||||
?>
|
Loading…
Reference in New Issue