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 /public/app/controllers/cli | |
| 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 'public/app/controllers/cli')
| -rw-r--r-- | public/app/controllers/cli/CliContoller.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/public/app/controllers/cli/CliContoller.php b/public/app/controllers/cli/CliContoller.php new file mode 100644 index 0000000..4549b50 --- /dev/null +++ b/public/app/controllers/cli/CliContoller.php @@ -0,0 +1,55 @@ +<?php + +namespace app\controllers\cli; + +/** CliContoller + * + * A typical cli constoller; this one is used to + * re-generate cashes of commonly used entities + * with expensive queries like (ex:) categories; + * + * Proxy calls make use of PROXY_IGNORE_CACHE + * + * CliController calls Model methods who create + * cashed data with the exact same arguments as + * when called from the web interface; this way + * the Model::method(arguments) triplete creates + * the same keys as via the web interface. + * + * NOTE: Only Cli interface is allowed¨ + * `if (php_sapi_name() != 'cli') return false;` + * + * The Cli-interfaced script can run manualy or + * (most usual scenario) scheduled via a cron job + * in order to refresh cashes befor expiration. + * + * --------------------------------------------- + */ +class CliContoller +{ + + + /** (re-) cacheCategoriesTree + * regenerate cache for product_categories tree + * @param (void) + */ + public static function cacheCategoriesTree() + { + // Only Cli interface is allowed + if (php_sapi_name() != 'cli') return false; + + # PROXY call: + # CMS \ Course_model::courses_struct(): + # + Refresh Cache + # -------------------------------------- + echo textColor("Creating category_products tree Cache ... ", \NORMAL); + $reply = proxy( + [\app\models\cms\Course_model::class, 'courses_struct'], + [], \CACHE_ROOT_TTL, + \PROXY_IGNORE_CACHE + ); + echo ($reply == false) ? textColor("Failed\n", \FAIL) : textColor("Done!\n", \SUCCESS); + } + + +}
\ No newline at end of file |
