43 $apcVersion = phpversion(
'apc');
44 $xcVersion = phpversion(
'xcache');
46 static::$supportedCaches = array(
50 'active' => extension_loaded(
'Zend OPcache') && ini_get(
'opcache.enable') ===
'1',
51 'version' => phpversion(
'Zend OPcache'),
56 'canInvalidate' => function_exists(
'opcache_invalidate'),
58 'clearCallback' =>
function ($fileAbsPath) {
59 if ($fileAbsPath !== NULL && function_exists(
'opcache_invalidate')) {
60 opcache_invalidate($fileAbsPath);
72 'active' => extension_loaded(
'apc') && !extension_loaded(
'apcu') && ini_get(
'apc.enabled') ===
'1',
73 'version' => $apcVersion,
76 'canInvalidate' => self::canApcInvalidate(),
79 'clearCallback' =>
function ($fileAbsPath) {
81 if (is_dir($fileAbsPath)) {
84 $quotedPath = preg_quote(rtrim($fileAbsPath,
'/') .
'/',
'/');
85 $iterator = new \APCIterator(
'file',
'/^'. $quotedPath .
'.*/');
86 apc_delete_file($iterator);
88 apc_delete_file($fileAbsPath);
92 apc_clear_cache(
'opcode');
99 'active' => extension_loaded(
'wincache') && ini_get(
'wincache.ocenabled') ===
'1' 100 && version_compare(phpversion(
'wincache'),
'2.0.0.0',
'<'),
101 'version' => phpversion(
'wincache'),
103 'canInvalidate' => TRUE,
105 'clearCallback' =>
function ($fileAbsPath) {
106 if ($fileAbsPath !== NULL) {
107 wincache_refresh_if_changed(array($fileAbsPath));
110 wincache_refresh_if_changed();
117 'active' => extension_loaded(
'xcache'),
118 'version' => $xcVersion,
120 'canInvalidate' => FALSE,
126 function ($fileAbsPath) {
127 if (!ini_get(
'xcache.admin.enable_auth')) {
128 xcache_clear_cache(XC_TYPE_PHP, 0);
132 function ($fileAbsPath) {
133 if (!ini_get(
'xcache.admin.enable_auth')) {
134 xcache_clear_cache(XC_TYPE_PHP);
145 'eAccelerator' => array(
146 'active' => extension_loaded(
'eAccelerator'),
147 'version' => phpversion(
'eaccelerator'),
149 'canInvalidate' => FALSE,
151 'clearCallback' =>
function ($fileAbsPath) {
152 eaccelerator_clear();
158 'ZendOptimizerPlus' => array(
159 'active' => extension_loaded(
'Zend Optimizer+') && ini_get(
'zend_optimizerplus.enable') ===
'1',
160 'version' => phpversion(
'Zend Optimizer+'),
162 'canInvalidate' => FALSE,
164 'clearCallback' =>
function ($fileAbsPath) {
170 static::$activeCaches = array();
172 foreach (static::$supportedCaches as $opcodeCache => $properties) {
173 if ($properties[
'active']) {
174 static::$activeCaches[$opcodeCache] = $properties;
188 return isset(static::$supportedCaches[$system])
189 ? static::$supportedCaches[$system][
'canInvalidate']
201 foreach (static::getAllActive() as $properties) {
202 $callback = $properties[
'clearCallback'];
203 $callback($fileAbsPath);
213 if (static::$activeCaches === NULL) {
214 static::initialize();
216 return static::$activeCaches;
227 $canInvalidate = FALSE;
229 if (function_exists(
'apc_delete_file')) {
235 $stat = (int)ini_get(
'apc.stat');
237 $canonicalize = (int)ini_get(
'apc.canonicalize');
240 $protection = (int)ini_get(
'apc.file_update_protection');
242 if ($protection === 0 || ($stat === 0 && $canonicalize === 1)) {
243 $canInvalidate = TRUE;
247 return $canInvalidate;
static getCanInvalidate($system)
static clearAllActive($fileAbsPath=NULL)
static convertVersionNumberToInteger($versionNumber)
static canApcInvalidate()