-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear cache processing #2962
Clear cache processing #2962
Conversation
$deleted = 0; | ||
$log = fopen('./cli/clearedLocalResults.log', 'w'); | ||
|
||
$MIN_DAYS = max($days_results_kept, 0.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 0.1? also we can just return early if days_results_kept is not set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.1
was carried over from archive.php. We don't do any processing if $days_results_kept
is not set, we just add a couple log statements. I can return early, but similarly this follows the archive flow.
www/cli/clearCache.php
Outdated
* @param mixed $logFile | ||
* @param mixed $match | ||
*/ | ||
function CheckTest($testPath, $id, $elapsedDays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function CheckTest($testPath, $id, $elapsedDays) | |
function DeleteExpiredTest($testPath, $id, $elapsedDays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed name
www/cli/clearCache.php
Outdated
* @param mixed $dir | ||
* @param mixed $baseID | ||
*/ | ||
function CheckDay($dir, $baseID, $elapsedDays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those "checks" are a bit misleading
function CheckDay($dir, $baseID, $elapsedDays) | |
function DeleteTestsExpiredOn($dir, $baseID, $elapsedDays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a little opportunity for cleanup of unused code.
www/cli/clearCache.php
Outdated
foreach ($days as $day) { | ||
$dayDir = "$monthDir/$day"; | ||
if (is_dir($dayDir) && $day != '.' && $day != '..') { | ||
$elapsedDays = ElapsedDays($year, $month, $day); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the $elapsedDays (and from the passed-into functions). That is the elapsed time based on the test ID but it's not used for this cache cleanup. The actual cleanup is entirely done with "last accessed" time for the test.
www/cli/clearCache.php
Outdated
/** | ||
* Calculate how many days have passed since the given day | ||
*/ | ||
function ElapsedDays($year, $month, $day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function isn't needed.
Add cached result processing.