- new map change log to Slack channel - new "rally point" logging to Slack channel - new "rally point" poke options (e.g. custom message), closed #295 - new log options for WebSocket installations - added ship "mass" logging (backend only), #313 - added map logging to Slack, #326 - added "ESI error rate" limit detection - added "Monolog" as new logging library (Composer dependency) - added "Swiftmailer" as new eMail library (Composer dependency) - added Support for Redis session hander (performance boost) - improved character select panels (visible "online" status) - improved "activity logging" (more DB columns added to check) - improved eMail logging (HTML template support) - improved "delete map" now become "inactive" for some days before delete - improved character logout handling - improved /setup page for DB bootstrap (new button for DB create if not exists) - fixed broken ship tracking (ship name re-added) - fixed broken ship tracking for multiple chars on different browser tabs - fixed broken cursor coordinates, closed #518 - fixed null pointer "charactermodel.php->isActive():925" closed #529 - fixed broken "scroll offset", closed #533 closed #534 - Updated "validation" library JS v0.10.1 -> v0.11.9 - Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0 - and many more....
76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Exodus
|
|
* Date: 25.06.2016
|
|
* Time: 14:59
|
|
*/
|
|
|
|
namespace cron;
|
|
|
|
use data\filesystem\Search;
|
|
|
|
class Cache {
|
|
|
|
const LOG_TEXT = '%s [%\'_10s] files, size [%\'_10s] byte, not writable [%\'_10s] files, errors [%\'_10s], exec (%.3Fs)';
|
|
|
|
/**
|
|
* default max expire for files (seconds)
|
|
*/
|
|
const CACHE_EXPIRE_MAX = 864000;
|
|
|
|
/**
|
|
* @param \Base $f3
|
|
* @return int
|
|
*/
|
|
protected function getExpireMaxTime(\Base $f3): int {
|
|
$expireTime = (int)$f3->get('PATHFINDER.CACHE.EXPIRE_MAX');
|
|
return ($expireTime >= 0) ? $expireTime : self::CACHE_EXPIRE_MAX;
|
|
}
|
|
|
|
/**
|
|
* clear expired cached files
|
|
* >> php index.php "/cron/deleteExpiredCacheData"
|
|
* @param \Base $f3
|
|
*/
|
|
function deleteExpiredData(\Base $f3){
|
|
$time_start = microtime(true);
|
|
|
|
// cache dir (dir is recursively searched...)
|
|
$cacheDir = $f3->get('TEMP');
|
|
|
|
$filterTime = (int)strtotime('-' . $this->getExpireMaxTime($f3) . ' seconds');
|
|
$expiredFiles = Search::getFilesByMTime($cacheDir, $filterTime, Search::DEFAULT_FILE_LIMIT);
|
|
|
|
$deletedFiles = 0;
|
|
$deletedSize = 0;
|
|
$notWritableFiles = 0;
|
|
$deleteErrors = 0;
|
|
foreach($expiredFiles as $filename => $file) {
|
|
/**
|
|
* @var $file \SplFileInfo
|
|
*/
|
|
if($file->isFile()){
|
|
if( $file->isWritable() ){
|
|
$tmpSize = $file->getSize();
|
|
if( unlink($file->getRealPath()) ){
|
|
$deletedSize += $tmpSize;
|
|
$deletedFiles++;
|
|
}else{
|
|
$deleteErrors++;
|
|
}
|
|
}else{
|
|
$notWritableFiles++;
|
|
}
|
|
}
|
|
}
|
|
|
|
$execTime = microtime(true) - $time_start;
|
|
|
|
// Log ------------------------
|
|
$log = new \Log('cron_' . __FUNCTION__ . '.log');
|
|
$log->write( sprintf(self::LOG_TEXT, __FUNCTION__, $deletedFiles, $deletedSize, $notWritableFiles, $deleteErrors, $execTime) );
|
|
}
|
|
|
|
}
|