/** * Flush the OPcache whenever an upgrade occurs. * * @since 160620 Adding support for OPcache flushing. */ function ___wp_sharks_core_rv_on_upgrader_process_complete__on_shutdown() { // NOTE: Avoid relying on objects in the shutdown phase. // PHP's shutdown phase is known to destruct objects randomly. if (function_exists('opcache_reset')) { @opcache_reset(); } }
public function purgeOPcache() { if (!extension_loaded('Zend OPcache')) { return; } opcache_reset(); }
/** * Reset opcache. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function opcacheReset(Request $request) { if ('127.0.0.1' === $request->ip()) { opcache_reset(); } return response()->json('', 200); }
/** * Returns all supported and active opcaches * * @return array Array filled with supported and active opcaches */ public function getAllActive() { $xcVersion = phpversion('xcache'); $supportedCaches = array('OPcache' => array('active' => extension_loaded('Zend OPcache') && ini_get('opcache.enable') === '1', 'version' => phpversion('Zend OPcache'), 'canReset' => TRUE, 'canInvalidate' => function_exists('opcache_invalidate'), 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) { if ($fileAbsPath !== NULL && function_exists('opcache_invalidate')) { opcache_invalidate($fileAbsPath); } else { opcache_reset(); } }), 'WinCache' => array('active' => extension_loaded('wincache') && ini_get('wincache.ocenabled') === '1', 'version' => phpversion('wincache'), 'canReset' => TRUE, 'canInvalidate' => TRUE, 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) { if ($fileAbsPath !== NULL) { wincache_refresh_if_changed(array($fileAbsPath)); } else { // No argument means refreshing all. wincache_refresh_if_changed(); } }), 'XCache' => array('active' => extension_loaded('xcache'), 'version' => $xcVersion, 'canReset' => !ini_get('xcache.admin.enable_auth'), 'canInvalidate' => FALSE, 'error' => FALSE, 'clearCallback' => function ($fileAbsPath) { if (!ini_get('xcache.admin.enable_auth')) { xcache_clear_cache(XC_TYPE_PHP); } })); $activeCaches = array(); foreach ($supportedCaches as $opcodeCache => $properties) { if ($properties['active']) { $activeCaches[$opcodeCache] = $properties; } } return $activeCaches; }
/** * Resets the opcache if it is available on the server and if we are not on a production server. This can be very * useful for you are working locally and you don't want to deal with cached responses from the server. This * feature is excluded from production environments since it is typically desired to use as much caching as * possible in order to improve the user experience * * @param $request * @param callable $next * @return mixed */ public function handle($request, Closure $next) { if (env('APP_ENV') != 'production' && function_exists('opcache_reset')) { opcache_reset(); } return $next($request); }
public static function setTimestamp($value = null) { if (function_exists('\\opcache_reset')) { \opcache_reset(); } return $value; }
/** * Initialize the ClearCache-Callbacks * * @return void */ protected static function initialize() { self::$clearCacheCallbacks = array(); // Zend OpCache (built in by default since PHP 5.5) - http://php.net/manual/de/book.opcache.php if (extension_loaded('Zend OPcache') && ini_get('opcache.enable') === '1') { self::$clearCacheCallbacks[] = function ($absolutePathAndFilename) { if ($absolutePathAndFilename !== null && function_exists('opcache_invalidate')) { opcache_invalidate($absolutePathAndFilename); } else { opcache_reset(); } }; } // WinCache - http://www.php.net/manual/de/book.wincache.php if (extension_loaded('wincache') && ini_get('wincache.ocenabled') === '1') { self::$clearCacheCallbacks[] = function ($absolutePathAndFilename) { if ($absolutePathAndFilename !== null) { wincache_refresh_if_changed(array($absolutePathAndFilename)); } else { // Refresh everything! wincache_refresh_if_changed(); } }; } // XCache - http://xcache.lighttpd.net/ // Supported in version >= 3.0.1 if (extension_loaded('xcache')) { self::$clearCacheCallbacks[] = function ($absolutePathAndFilename) { // XCache can only be fully cleared. if (!ini_get('xcache.admin.enable_auth')) { xcache_clear_cache(XC_TYPE_PHP); } }; } }
/** * {@inheritDoc} */ function purge() { // Purge all phpbb cache files try { $iterator = new \DirectoryIterator($this->cache_dir); } catch (\Exception $e) { return; } foreach ($iterator as $fileInfo) { if ($fileInfo->isDot()) { continue; } $filename = $fileInfo->getFilename(); if ($fileInfo->isDir()) { $this->remove_dir($fileInfo->getPathname()); } else { if (strpos($filename, 'container_') === 0 || strpos($filename, 'url_matcher') === 0 || strpos($filename, 'sql_') === 0 || strpos($filename, 'data_') === 0) { $this->remove_file($fileInfo->getPathname()); } } } unset($this->vars); unset($this->sql_rowset); unset($this->sql_row_pointer); if (function_exists('opcache_reset')) { @opcache_reset(); } $this->vars = array(); $this->sql_rowset = array(); $this->sql_row_pointer = array(); $this->is_modified = false; }
/** * Constructor. */ public function __construct() { if (function_exists('opcache_reset')) { opcache_reset(); } $this->config = file_exists($this->configFile); }
public function __construct(Application $app) { $this->app = $app; if (function_exists('opcache_reset')) { opcache_reset(); } $this->config = file_exists($this->configFile); }
/** * 当socket服务启动时,回调此方法 */ public static function onStart() { echo 'swoole start, swoole version: ' . SWOOLE_VERSION . PHP_EOL; //FIXME 完善opcode 清理功能 if (extension_loaded('Zend OPcache')) { opcache_reset(); } }
public function main() { if (opcache_reset()) { $this->success('Opcache clear complete'); } else { $this->err("Error : Opcache clear failed"); } }
protected function export() { $fileData = '<?php ' . "\n return " . var_export($this->_activePlugins, true) . ';'; file_put_contents($this->configFile, $fileData); if (function_exists('opcache_reset')) { opcache_reset(); } }
public function reset_call() { if (isset($_POST['opcache_reset'])) { opcache_reset(); error_log('OP Cache Reset call made'); } die; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->app->environment() != 'production') { if (function_exists('opcache_reset')) { opcache_reset(); } } return $next($request); }
/** * Execute the console command. * * @return mixed */ public function fire() { if (function_exists('opcache_reset')) { opcache_reset(); $this->info("Done Clear PHP Opcode Cache, have a good day."); } else { $this->info("You haven't install PHP Opcode Cache yet, no need to run this command!"); } }
protected function writeConfig() { $writer = new PhpArray(); $writer->toFile('data/rcm/config.php', $this->config, true); chmod('data/rcm/config.php', 0666); if (extension_loaded('Zend OPcache')) { opcache_reset(); } }
/** * Allows to clear the internal php opcache. Listens to EVENT_OPCACHE_RESET * @param OnInteractionEvent The event to listen to */ public static final function opcacheReset(\System\System\Interaction\Event\OnInteractionEvent $event) { $msg = $event->getMessage(); if ($msg->getType() == \System\System\Interaction\MessageType::TYPE_SYSTEM && $msg->getMessage() == SystemInteractionEventEvent::EVENT_OPCACHE_RESET) { $reset = opcache_reset(); $response = new \System\System\Interaction\Response($msg, $reset ? 'OK' : 'Error'); $event->addResponse($response); } }
/** * Deletes cache in PHP caching module(s) * @return boolean */ private function clearCache() { // Prevent caching if opcache is present if (function_exists('opcache_reset')) { opcache_reset(); return true; } return false; }
public function reset() { try { opcache_reset(); } catch (\Exception $e) { \Dsc\System::addMessage($e->getMessage(), 'error'); } $this->app->reroute('/admin/cache/opcache'); }
/** * Clear opcode caches to make sure that the * updated files are used in the following requests. */ public static function clearOpcodeCache() { if (function_exists('opcache_reset')) { opcache_reset(); } if (function_exists('apc_clear_cache')) { apc_clear_cache(); apc_clear_cache('user'); } }
/** * @return string */ private static function clearOpcodeCache() { if (function_exists('opcache_reset') && opcache_reset()) { return 'Zend OPcache: success.'; } if (function_exists('apc_clear_cache') && apc_clear_cache('opcode')) { return 'APC Opcode Cache: success.'; } throw new \RuntimeException('Opcode Cache: failure.'); }
public function onWorkerStart($server, $workerId) { if ($workerId >= ZConfig::getField('socket', 'worker_num')) { swoole_set_process_name(ZConfig::get('project_name') . " server task num: {$server->worker_id} pid " . $server->worker_pid); } else { swoole_set_process_name(ZConfig::get('project_name') . " server worker num: {$server->worker_id} pid " . $server->worker_pid); } if (function_exists('opcache_reset')) { opcache_reset(); } }
/** * Execute the console command. * * @return mixed */ public function handle() { opcache_reset(); $adapter = new FastCGI('/dev/shm/php-cgi.sock'); $cache = new CacheTool(); $cache->setAdapter($adapter); $cache->addProxy(new Proxy\OpcacheProxy()); $cache->addProxy(new Proxy\PhpProxy()); $cache->opcache_reset(); echo 'a'; }
public function onWorkerStart($server, $worker_id) { global $argv; opcache_reset(); include_once dirname(__FILE__) . "/test/test.php"; if ($worker_id >= $this->_server->setting['worker_num']) { swoole_set_process_name("php {$argv[0]} task worker"); } else { swoole_set_process_name("php {$argv[0]} event worker"); } }
/** * */ static function clearFilesCache() { if (function_exists('clearstatcache')) { clearstatcache(); } if (function_exists('opcache_reset')) { opcache_reset(); } if (function_exists('apc_clear_cache')) { apc_clear_cache(); } }
public function purge() { $this->emptyFolder(JPATH_SITE . '/cache'); $this->emptyFolder(JPATH_ADMINISTRATOR . '/cache'); $cache = $this->getCache(); if (isset($cache->options['storage']) && $cache->options['storage'] != 'file') { $cache->clean(null, 'all'); } if (extension_loaded('Zend OPcache')) { opcache_reset(); } }
function clearOpcodeCaches() { if (function_exists('opcache_reset')) { opcache_reset(); } if (ini_get('wincache.ocenabled')) { wincache_refresh_if_changed(); } if (ini_get('apc.enabled') && function_exists('apc_clear_cache')) { apc_clear_cache(); } }
/** * Cache action. * * @param string $token A configured token * * @return Response * * @throws AccessDeniedHttpException */ public function cacheAction($token) { if ($this->token == $token) { if (version_compare(PHP_VERSION, '5.5.0', '>=') && function_exists('opcache_reset')) { opcache_reset(); } elseif ($this->hasApc()) { apc_clear_cache('user') && apc_clear_cache(); } return new Response('ok', 200, array('Cache-Control' => 'no-cache, must-revalidate', 'Content-Length' => 2)); } throw new AccessDeniedHttpException('invalid token'); }
/** * @Route("/opcache-clear/{version}/", name="_enuygun_com_opcache_clear") * @param Request $request * @param $version * @return array */ public function opcacheClearAction(Request $request, $version) { $ipFilter = $this->container->getParameter('enuygun_com_opcache_clear.ip_filter'); if (!empty($ipFilter) && !in_array($request->getClientIp(), $ipFilter)) { return new JsonResponse(array('success' => false, 'message' => $request->getClientIp() . ' is not allowed'), 400, array('x-enuygun-opcache-clear' => json_encode(array('success' => false, 'message' => $request->getClientIp() . ' is not allowed', 'version' => $version)))); } if (!function_exists('opcache_reset')) { throw new \RuntimeException('Opcache extension is not enabled.'); } $success = opcache_reset(); $message = 'Opcache cleared: ' . ($success ? 'success' : 'failed'); return new JsonResponse(array('success' => $success, 'message' => $message), 200, array('x-enuygun-opcache-clear' => json_encode(array('success' => $success, 'message' => $message, 'version' => $version)))); }