Skip to content
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

Merged
merged 9 commits into from
Aug 28, 2023
Merged

Clear cache processing #2962

merged 9 commits into from
Aug 28, 2023

Conversation

mjkozicki
Copy link
Contributor

Add cached result processing.

@mjkozicki mjkozicki self-assigned this Aug 16, 2023
$deleted = 0;
$log = fopen('./cli/clearedLocalResults.log', 'w');

$MIN_DAYS = max($days_results_kept, 0.1);
Copy link
Contributor

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

Copy link
Contributor Author

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.

* @param mixed $logFile
* @param mixed $match
*/
function CheckTest($testPath, $id, $elapsedDays)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function CheckTest($testPath, $id, $elapsedDays)
function DeleteExpiredTest($testPath, $id, $elapsedDays)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed name

* @param mixed $dir
* @param mixed $baseID
*/
function CheckDay($dir, $baseID, $elapsedDays)
Copy link
Contributor

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

Suggested change
function CheckDay($dir, $baseID, $elapsedDays)
function DeleteTestsExpiredOn($dir, $baseID, $elapsedDays)

Copy link
Contributor

@pmeenan pmeenan left a 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.

foreach ($days as $day) {
$dayDir = "$monthDir/$day";
if (is_dir($dayDir) && $day != '.' && $day != '..') {
$elapsedDays = ElapsedDays($year, $month, $day);
Copy link
Contributor

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.

/**
* Calculate how many days have passed since the given day
*/
function ElapsedDays($year, $month, $day)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function isn't needed.

@mjkozicki mjkozicki merged commit d59fba2 into master Aug 28, 2023
1 check passed
@mjkozicki mjkozicki deleted the local_cache_clear branch August 28, 2023 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants