blob: 949985de6134e1ce5a9628b7d9c72b74f0db712e (
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
|
<?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 \ Cms_model::courses_struct():
# + Refresh Cache
# --------------------------------------
echo textColor("Creating category_products tree Cache ... ", \NORMAL);
$reply = proxy(
[\app\models\Cms_model::class, 'courses_struct'],
[], \CACHE_ROOT_TTL,
\PROXY_IGNORE_CACHE
);
echo ($reply == false) ? textColor("Failed\n", \FAIL) : textColor("Done!\n", \SUCCESS);
}
}
|