• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP opcache_get_status函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中opcache_get_status函数的典型用法代码示例。如果您正苦于以下问题:PHP opcache_get_status函数的具体用法?PHP opcache_get_status怎么用?PHP opcache_get_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了opcache_get_status函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: shutdown

 public function shutdown($context, &$storage)
 {
     if ($this->shutdownCalled) {
         return;
     }
     $this->shutdownCalled = true;
     $status = opcache_get_status();
     $config = opcache_get_configuration();
     $storage['opMemoryUsage'][] = $status['memory_usage'];
     $storage['opInternedStringsUsage'][] = $status['interned_strings_usage'];
     $storage['opStatistics'][] = $status['opcache_statistics'];
     $storage['opDirectives'][] = $config['directives'];
     $storage['opVersion'][] = $config['version'];
     $storage['opBlacklist'][] = $config['blacklist'];
     $scripts = $status['scripts'];
     array_walk($scripts, function (&$item, $key) {
         $item = array_merge(array('name' => basename($item['full_path'])), array('Full Path' => $item['full_path']), $item);
         $item['memory Consumption'] = round($item['memory_consumption'] / 1024) . " KB ({$item['memory_consumption']} B)";
         $item['Last Used'] = $item['last_used'];
         $item['Last Used Timestamp'] = $item['last_used_timestamp'];
         $item['created'] = date("D M j G:i:s Y", $item['timestamp']);
         $item['created Timestamp'] = $item['timestamp'];
         unset($item['full_path']);
         unset($item['memory_consumption']);
         unset($item['last_used']);
         unset($item['last_used_timestamp']);
         unset($item['timestamp']);
     });
     $storage['opcacheScripts'] = $scripts;
 }
开发者ID:anyatar,项目名称:Z-Ray-OPcache,代码行数:30,代码来源:OPcache.php


示例2: renderLoadedFiles

 public function renderLoadedFiles($tableName)
 {
     $status = opcache_get_status(true);
     $loadedFiles = get_included_files();
     $scriptInfo = array();
     if (isset($status['scripts']) == false) {
         return "Failed to load scripts info to generate OPCache info.";
     }
     foreach ($loadedFiles as $loadedFile) {
         $newScriptInfo = array();
         if (array_key_exists($loadedFile, $status['scripts']) == true) {
             $newScriptInfo["memory_consumption"] = $status['scripts'][$loadedFile]["memory_consumption"];
             $newScriptInfo["hits"] = $status['scripts'][$loadedFile]["hits"];
         } else {
             $newScriptInfo["memory_consumption"] = "-";
             $newScriptInfo["hits"] = "-";
         }
         $newScriptInfo['path'] = $loadedFile;
         if (mb_strpos($loadedFile, $this->root) === 0) {
             $newScriptInfo['path'] = '.' . mb_substr($loadedFile, mb_strlen($this->root));
         }
         $scriptInfo[] = $newScriptInfo;
     }
     return $this->renderTable($tableName, $scriptInfo);
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:25,代码来源:OPCacheInfo.php


示例3: initOpcacheSpec

 private function initOpcacheSpec()
 {
     $this->setName(pht('Zend OPcache'))->setVersion(phpversion('Zend OPcache'));
     if (ini_get('opcache.enable')) {
         $this->setIsEnabled(true)->setClearCacheCallback('opcache_reset');
         $status = opcache_get_status();
         $memory = $status['memory_usage'];
         $mem_used = $memory['used_memory'];
         $mem_free = $memory['free_memory'];
         $mem_junk = $memory['wasted_memory'];
         $this->setUsedMemory($mem_used + $mem_junk);
         $this->setTotalMemory($mem_used + $mem_junk + $mem_free);
         $this->setEntryCount($status['opcache_statistics']['num_cached_keys']);
         $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
         $validate = ini_get('opcache.validate_timestamps');
         $freq = ini_get('opcache.revalidate_freq');
         if ($is_dev && (!$validate || $freq)) {
             $summary = pht('OPcache is not configured properly for development.');
             $message = pht('In development, OPcache should be configured to always reload ' . 'code so nothing needs to be restarted after making changes. To do ' . 'this, enable "%s" and set "%s" to 0.', 'opcache.validate_timestamps', 'opcache.revalidate_freq');
             $this->newIssue('extension.opcache.devmode')->setShortName(pht('OPcache Config'))->setName(pht('OPCache Not Configured for Development'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.validate_timestamps')->addPHPConfig('opcache.revalidate_freq')->addPhabricatorConfig('phabricator.developer-mode');
         } else {
             if (!$is_dev && $validate) {
                 $summary = pht('OPcache is not configured ideally for production.');
                 $message = pht('In production, OPcache should be configured to never ' . 'revalidate code. This will slightly improve performance. ' . 'To do this, disable "%s" in your PHP configuration.', 'opcache.validate_timestamps');
                 $this->newIssue('extension.opcache.production')->setShortName(pht('OPcache Config'))->setName(pht('OPcache Not Configured for Production'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.validate_timestamps')->addPhabricatorConfig('phabricator.developer-mode');
             }
         }
     } else {
         $this->setIsEnabled(false);
         $summary = pht('Enabling OPcache will dramatically improve performance.');
         $message = pht('The PHP "Zend OPcache" extension is installed, but not enabled in ' . 'your PHP configuration. Enabling it will dramatically improve ' . 'Phabricator performance. Edit the "%s" setting to ' . 'enable the extension.', 'opcache.enable');
         $this->newIssue('extension.opcache.enable')->setShortName(pht('OPcache Disabled'))->setName(pht('Zend OPcache Not Enabled'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.enable');
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhabricatorOpcodeCacheSpec.php


示例4: collect

 /**
  * {@inheritDoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     // This is needed to support the PHP 5.5 opcache as well as the old ZendOptimizer+-extension.
     if (function_exists('opcache_get_status')) {
         $status = opcache_get_status();
         $config = opcache_get_configuration();
         $version = $config['version']['opcache_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['opcache_statistics'];
         $hitrate = $stats['opcache_hit_rate'];
     } elseif (function_exists('accelerator_get_status')) {
         $status = accelerator_get_status();
         $config = accelerator_get_configuration();
         $version = $config['version']['accelerator_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['accelerator_statistics'];
         $hitrate = $stats['accelerator_hit_rate'];
     }
     $filelist = array();
     if ($this->showFilelist) {
         foreach ($status['scripts'] as $key => $data) {
             $filelist[$key] = $data;
             $filelist[$key]['name'] = basename($key);
         }
     }
     // unset unneeded filelist to lower memory-usage
     unset($status['scripts']);
     $this->data = array('version' => $version, 'ini' => $config['directives'], 'filelist' => $filelist, 'status' => $status, 'stats' => $stats, 'hitrate' => $hitrate);
 }
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:30,代码来源:OpcacheDataCollector.php


示例5: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     if (extension_loaded('Zend OPcache')) {
         $this->_opCacheStats = opcache_get_status();
         $this->_opCacheConfig = opcache_get_configuration();
     }
 }
开发者ID:unifiedarts,项目名称:Hackathon_MageMonitoring,代码行数:10,代码来源:Zendopcache.php


示例6: __construct

 public function __construct($get_scripts = FALSE)
 {
     $this->statusData = opcache_get_status($get_scripts);
     if ($get_scripts) {
         $this->scripts = $this->statusData['scripts'];
     }
 }
开发者ID:reload,项目名称:dockhub-testing,代码行数:7,代码来源:OPCacheStatus.php


示例7: opCacheEnabled

 /**
  * Whether or not PHP-OPcache is loaded and enabled
  * @return boolean true if loaded
  */
 public static function opCacheEnabled()
 {
     if (!static::extOpCacheLoaded()) {
         return false;
     }
     $status = opcache_get_status();
     return $status['opcache_enabled'];
 }
开发者ID:highestgoodlikewater,项目名称:yii2-toolbox,代码行数:12,代码来源:ServerConfig.php


示例8: lintFile

 /**
  * @param string $path
  *
  * @return bool
  */
 private function lintFile($path)
 {
     static $linter;
     if (empty($linter)) {
         $linter = !empty(opcache_get_status(false)['opcache_enabled']) ? [$this, 'opcacheLint'] : [$this, 'commandLineLint'];
     }
     return call_user_func($linter, $path);
 }
开发者ID:ossistyle,项目名称:http-client-description,代码行数:13,代码来源:PhpFileLinterTrait.php


示例9: status

 /**
  * Get OpCache status data
  * @param void
  * @access public
  * @return array
  */
 public function status()
 {
     $status = null;
     if (function_exists('opcache_get_status')) {
         $status = opcache_get_status();
     }
     return $status;
 }
开发者ID:sandeepdwarkapuria,项目名称:dotkernel,代码行数:14,代码来源:OpCache.php


示例10: opcode

 public function opcode()
 {
     $i = opcache_get_status();
     var_dump($i);
     $file = '/vagrant/simplephpmvc/Caches/test.php';
     // $v = opcache_compile_file($file);
     // var_dump($v);
     // $v2 = opcache_is_script_cached($file);
     var_dump($v2);
 }
开发者ID:xinzhanguo,项目名称:simplephpmvc,代码行数:10,代码来源:Test.php


示例11: __construct

 public function __construct()
 {
     if (!function_exists('opcache_compile_file')) {
         throw new \Exception("The OpCache extension isn't available!");
     }
     $status = opcache_get_status(true);
     $this->memory = $status['memory_usage'];
     $this->statistics = $status['opcache_statistics'];
     $this->scripts = $status['scripts'];
 }
开发者ID:Tacsiazuma,项目名称:GW_System,代码行数:10,代码来源:OpCache.php


示例12: check

 /**
  * Perform the check
  *
  * @see \ZendDiagnostics\Check\CheckInterface::check()     *
  * @return Failure|Skip|Success|Warning
  */
 public function check()
 {
     if (!function_exists('opcache_get_status')) {
         return new Warning('Zend OPcache extension is not available');
     }
     $this->opCacheInfo = opcache_get_status(false);
     if (!is_array($this->opCacheInfo) || !array_key_exists('memory_usage', $this->opCacheInfo)) {
         return new Warning('Zend OPcache extension is not enabled in this environment');
     }
     return parent::check();
 }
开发者ID:atulhere,项目名称:zendPractice,代码行数:17,代码来源:OpCacheMemory.php


示例13: __construct

 public function __construct()
 {
     if (!extension_loaded('Zend OPcache')) {
         $this->_opcacheEnabled = false;
     } else {
         $this->_opcacheEnabled = true;
     }
     if ($this->_opcacheEnabled) {
         $this->_configuration = opcache_get_configuration();
         $this->_status = opcache_get_status();
     }
 }
开发者ID:omnilight,项目名称:yz2-admin,代码行数:12,代码来源:OpCacheDataModel.php


示例14: doClean

 /**
  * Removes files from the opcache. This assumes that the files still
  * exist on the instance in a previous checkout.
  *
  * @return int
  */
 public function doClean()
 {
     $status = opcache_get_status(true);
     $filter = new StaleFiles($status['scripts'], $this->path);
     $files = $filter->filter();
     foreach ($files as $file) {
         $status = opcache_invalidate($file['full_path'], true);
         if (false === $status) {
             $this->log(sprintf('Could not validate "%s".', $file['full_path']), 'error');
         }
     }
     return 0;
 }
开发者ID:TicketSwap,项目名称:opcache-primer,代码行数:19,代码来源:Prime.php


示例15: getStatusDataRows

 public function getStatusDataRows()
 {
     $stats = opcache_get_status();
     foreach ($stats as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $k => $v) {
                 echo $k;
                 echo ':';
                 echo $v;
                 echo ';';
             }
         }
     }
 }
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:14,代码来源:opcache.php


示例16: opcache_is_script_cached

 function opcache_is_script_cached($file)
 {
     if (\extension_loaded('Zend OPCache')) {
         $opcached_files = opcache_get_status();
         if (array_key_exists('scripts', $opcached_files)) {
             foreach ($opcached_files['scripts'] as $cache_file) {
                 $fullpath = $cache_file['full_path'];
                 if (normalize_pathfile($fullpath) == normalize_pathfile($file)) {
                     return true;
                 }
             }
         }
         return false;
     }
     return false;
 }
开发者ID:smnDev,项目名称:pheeca,代码行数:16,代码来源:compatibility.php


示例17: getIndex

 public function getIndex()
 {
     if (!$this->checkAccessRead()) {
         return;
     }
     /*
      * Check if Laravel is compiled to one single file
      */
     $filename = app('path.base') . '/bootstrap/cache/compiled.php';
     if (File::exists($filename)) {
         $optimized = '1 - ' . trans('app.compiled') . ': ' . Carbon::createFromTimeStamp(filemtime($filename));
     } else {
         $optimized = 0;
     }
     /*
      * Count disabled modules
      */
     $moduleBase = app()['modules'];
     $disabled = sizeof($moduleBase->disabled());
     /*
      * Create array with names and values
      */
     $placeholder = Config::get('app.key') == '01234567890123456789012345678912';
     $appClass = get_class(app());
     $opcacheExists = (int) function_exists('opcache_get_status');
     $opcacheEnabled = $opcacheExists and opcache_get_status()['opcache_enabled'] ? 1 : 0;
     $settings = ['PHP.version' => phpversion(), 'PHP.os' => PHP_OS, 'PHP.ini' => php_ini_loaded_file(), 'PHP.memory_limit' => ini_get('memory_limit'), 'PHP.max_execution_time' => ini_get('max_execution_time'), 'PHP.post_max_size' => ini_get('post_max_size'), 'PHP.upload_max_filesize' => ini_get('upload_max_filesize'), 'Laravel.version' => $appClass::VERSION, 'Artisan optimized' => $optimized, 'App.environment' => App::environment(), 'App.url' => Config::get('app.url'), 'App.debug' => (int) Config::get('app.debug'), 'App.key' => $placeholder ? '<em>' . trans('app.placeholder') . '</em>' : trans('app.valid'), 'Cache.default' => Config::get('cache.default'), 'Modules.disabled' => $disabled, 'Mail.pretend' => (int) Config::get('mail.pretend'), 'OPcache.installed' => $opcacheExists, 'OPcache.enabled' => $opcacheEnabled, 'Xdebug.enabled' => extension_loaded('xdebug') ? 1 : 0];
     /*
      * If we use MySQL as database, add values of some MySQL variables.
      */
     if (Config::get('database.default') == 'mysql') {
         $fetchMethod = Config::get('database.fetch');
         DB::connection()->setFetchMode(PDO::FETCH_ASSOC);
         // We need to get the result as array of arrays
         $sqlVars = DB::select('SHOW VARIABLES');
         DB::connection()->setFetchMode($fetchMethod);
         $settings['MySQL.max_connections'] = $this->getSqlVar($sqlVars, 'max_connections');
         $settings['MySQL.max_user_connections'] = $this->getSqlVar($sqlVars, 'max_user_connections');
     }
     $this->pageView('diag::admin_index', compact('settings'));
 }
开发者ID:CyberFX,项目名称:Contentify,代码行数:41,代码来源:AdminDiagController.php


示例18: clearOpcache

 protected function clearOpcache()
 {
     $console = $this->getConsole();
     if (!(bool) ini_get('opcache.enable_cli')) {
         $console->writeLine('You must enable opcache in CLI before clearing opcode cache', Color::RED);
         $console->writeLine('Check the "opcache.enable_cli" setting in your php.ini (see http://www.php.net/opcache.configuration)');
         return;
     }
     $scripts = opcache_get_status(true)['scripts'];
     if (count($scripts) === 0) {
         $console->writeLine('No files cached in OPcache, aborting', Color::RED);
         return;
     }
     foreach (array_keys($scripts) as $file) {
         $result = opcache_invalidate($file, true);
         if (!$result) {
             $console->writeLine('Failed to clear opcode cache for ' . $file, Color::RED);
         }
     }
     $console->writeLine(sprintf('%s OPcache files cleared', count($scripts)), Color::GREEN);
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:21,代码来源:OpcodeCacheController.php


示例19: status

 public function status($with_scripts = false)
 {
     // Guard execution if the extension is not loaded.
     if (!extension_loaded("Zend OPcache")) {
         return json_encode([]);
     }
     // Clear out data from prevous run
     $this->result['status'] = null;
     $raw = \opcache_get_status($with_scripts);
     // The scripts output has a really non-optimal format
     // for JSON, the result is a hash with the full path
     // as the key. Let's strip the key and turn it into
     // a regular array.
     if ($with_scripts == true) {
         // Make a copy of the raw scripts and then strip it from
         // the data.
         $scripts = $raw['scripts'];
         unset($raw['scripts']);
         $this->result['scripts'] = [];
         // Loop over each script and strip the key.
         foreach ($scripts as $key => $val) {
             $this->result['scripts'][] = $val;
         }
         // Sort by memory consumption
         usort($this->result['scripts'], function ($a, $b) {
             if ($a["memory_consumption"] == $b["memory_consumption"]) {
                 return 0;
             }
             return $a["memory_consumption"] < $b["memory_consumption"] ? 1 : -1;
         });
     }
     $this->result['status'] = $raw;
     if ($this->statsd != null) {
         $this->send_to_statsd();
     }
     return json_encode($this->result);
 }
开发者ID:stevencorona,项目名称:opcache-json,代码行数:37,代码来源:Status.php


示例20: run

 static function run()
 {
     if ('upgrader_process_complete' != current_filter()) {
         // only clear opcache on core updates
         return false;
     }
     error_log('pl5 - run() at ' . __CLASS__);
     if (!function_exists('opcache_reset')) {
         return false;
     }
     if (!function_exists('opcache_get_configuration')) {
         error_log('OPCache is not installed/running');
         return false;
     }
     $data = opcache_get_status();
     $expired = array();
     if (empty($data['scripts'])) {
         error_log('no cached files');
         return false;
     }
     error_log(count($data['scripts']) . ' cached');
     foreach ($data['scripts'] as $file) {
         /* Added testing to see if timestamp was set - if not, opcache.revalidate_timestamp is off */
         if (empty($file['timestamp'])) {
             error_log("This script only works if opcache.validate_timestamps is true in php.ini");
             return false;
         }
         if (!empty($file['timestamp']) && !empty($file['full_path']) && (!file_exists($file['full_path']) || (int) $file['timestamp'] < filemtime($file['full_path']))) {
             $expired[] = $file['full_path'];
             opcache_invalidate($file['full_path'], true);
         }
     }
     error_log(count($expired) . ' deleted');
     opcache_reset();
     error_log('pl5 - cleared Opcache caches.');
 }
开发者ID:Pross,项目名称:pl-plugin-cache-clear,代码行数:36,代码来源:opcache.php



注:本文中的opcache_get_status函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP opcache_invalidate函数代码示例发布时间:2022-05-15
下一篇:
PHP opcache_get_configuration函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap