This article mainly introduces the configuration information of Asf PHP development resident in the system memory. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
The configuration file will be reloaded with each request. Even if the configuration file content has not been updated, it will be reloaded. This is a very bad design. (When Opcache is turned on, there is still execution time)
The content of the read configuration file is saved to the system memory, and the next request goes directly to the memory to read the data. Asf also provides a very simple configuration implementation Config Cache.
It is recommended to enable it in web application scenarios. Later versions may enable it by default
It also takes effect when enabled in CLI and multi-threaded mode, but the PHP script is released every time it is executed.
<?php ini_set('asf.cache_config_enable', 1); /* 开启配置文件缓存 */ ini_set('asf.cache_config_expire', 300); /* 设置缓存多少秒之后过期, 300 seconds by default */
<?php define('APP_PATH', dirname(__DIR__)); /* 缓存 config.ini 文件 */ $app = new Asf\Application(APP_PATH . '/config/config.ini'); $app->run();
<?php $conf_php = new Asf\Config\Php(CONFIG_PATH . '/config.db.php');
<?php $conf_ini = new Asf\Config\Ini(CONFIG_PATH . '/config.redis.ini');
<?php print_r(Asf\Application::getInstance()->getConfig()->toArray()); print_r(Asf\Config::get()->toArray());
Total transferred: 16109994 bytes HTML transferred: 14259994 bytes Requests per second: 6859.01 [#/sec] (mean) Time per request: 14.579 [ms] (mean) Time per request: 0.146 [ms] (mean, across all concurrent requests)
Total transferred: 16080000 bytes HTML transferred: 14230000 bytes Requests per second: 6398.22 [#/sec] (mean) Time per request: 15.629 [ms] (mean) Time per request: 0.156 [ms] (mean, across all concurrent requests)
Nginx load scheduler dual Tomcat load and session sharing MySQL back-end database
ThinkPHP5.0 Linux Apache/ Nginx rewrite URL configuration
The above is the detailed content of Asf PHP development configuration information is resident in system memory. For more information, please follow other related articles on the PHP Chinese website!