3 namespace Drupal\Component\Utility;
6 * Provides helpers to handle PHP opcode caches.
13 * Checks if OpCodeCache is enabled.
16 * TRUE if opcache is enabled, FALSE otherwise.
18 public static function isEnabled() {
19 return extension_loaded('Zend OPcache') && ini_get('opcache.enable');
23 * Invalidates a PHP file from a possibly active opcode cache.
25 * In case the opcode cache does not support to invalidate an individual file,
26 * the entire cache will be flushed.
28 * @param string $pathname
29 * The absolute pathname of the PHP file to invalidate.
31 public static function invalidate($pathname) {
32 clearstatcache(TRUE, $pathname);
34 // Check if the Zend OPcache is enabled and if so invalidate the file.
35 if (function_exists('opcache_invalidate')) {
36 opcache_invalidate($pathname, TRUE);