diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 03:47:30 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 03:47:30 +0300 |
| commit | 059e0d95d0c28bc5060e87e146eaf7411f51bf90 (patch) | |
| tree | 7c21ac432f16dde2329a0d5954d70711eceb48e6 /core/cli/cli-cache.php | |
| parent | 26cd8ee99659ef1926c96a049c93645ffc9b169d (diff) | |
| download | gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.gz gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.bz2 gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.zip | |
skeleton commit; based on an anom project
Diffstat (limited to 'core/cli/cli-cache.php')
| -rw-r--r-- | core/cli/cli-cache.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/core/cli/cli-cache.php b/core/cli/cli-cache.php new file mode 100644 index 0000000..57d8090 --- /dev/null +++ b/core/cli/cli-cache.php @@ -0,0 +1,65 @@ +#!/usr/local/bin/php +<?php + +/** cli-cache + * regenerates/refreshes caches. + * ------------------------------------------------------ + * + * The sctipt implements a micro-anom application + * that queries directry the project's models. + * + * Advantages vs curl-cache: + * --- + * + Runs out of the web/apache interface; + * + Has less requirements, uses less total resources; + * + Avoids the typical block/waiting/receiving delays; + * + (theoretically) it is a faster implementation + * + * ------------------------------------------------------ + */ +$t0 = microtime(true); // time benchmark + +require_once 'micro/term_utilities.php'; // terminal colors + +echo textColor("\nInterface: ", NORMAL) . textColor(php_sapi_name(), GREEN). "\n"; + + +/** anom-Cli app initialization + * ------------------------------------------------------ + */ +define('MINI_APP_BASE', __DIR__.'/'); +echo "Base directory is ". textColor(MINI_APP_BASE, GREEN) ."\n"; + +require_once MINI_APP_BASE.'/micro/setup.php'; +echo "System is ready;\n"; + + + +try { + # your code goes here ------------------------------------------------------ + + + // Re-create category_products tree Cache + app\controllers\cli\CliContoller::cacheCategoriesTree(); + + $categories = app\controllers\cli\CliContoller::getCategories(); + + + foreach($categories as $key => $category) { + + echo textColor( textWidth($category['Title'], 72), NORMAL); + app\controllers\cli\CliContoller::cacheCategoryByUrl($category['FullFriendlyUrl']); + } + + # end of script ------------------------------------------------------------ + +} catch(Exception $e) { // Basic error handling + echo 'Caught exception: ', textColor($e->getMessage(), ERROR), "\n"; + die(); +} + + +$dt = number_format( microtime(true) - $t0 , 0) ."sec"; + +// echo ending... +echo textColor("\nOperation Completed {$dt}\n\n", NORMAL); |
