blob: 57d809079a9ef58a3cada6e20c903aa3c46f2537 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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);
|