本文整理汇总了PHP中xcache_clear_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP xcache_clear_cache函数的具体用法?PHP xcache_clear_cache怎么用?PHP xcache_clear_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xcache_clear_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
public function clear()
{
if (!_cacheStatus) {
return FALSE;
}
xcache_clear_cache(XC_TYPE_VAR, 0);
}
示例2: initialize
/**
* 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);
}
};
}
}
示例3: clear
public function clear()
{
$admin = ini_get('xcache.admin.enable_auth') === "On";
if ($admin && (!isset($this->config['username']) || !isset($this->config['password']))) {
return false;
}
$credentials = array();
if (isset($_SERVER['PHP_AUTH_USER'])) {
$credentials['username'] = $_SERVER['PHP_AUTH_USER'];
$_SERVER['PHP_AUTH_USER'] = $this->config['username'];
}
if (isset($_SERVER['PHP_AUTH_PW'])) {
$credentials['password'] = $_SERVER['PHP_AUTH_PW'];
$_SERVER['PHP_AUTH_PW'] = $this->config['pass'];
}
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
return false;
}
}
if (isset($_SERVER['PHP_AUTH_USER'])) {
$_SERVER['PHP_AUTH_USER'] = $credentials['username'];
}
if (isset($_SERVER['PHP_AUTH_PW'])) {
$_SERVER['PHP_AUTH_PW'] = $credentials['password'];
}
return true;
}
示例4: clear
/**
* {@inheritdoc}
*/
public function clear()
{
$cleared = true;
// Set XCache password
$tempUsername = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : false;
$tempPassword = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : false;
$_SERVER['PHP_AUTH_USER'] = $this->username;
$_SERVER['PHP_AUTH_PW'] = $this->password;
// Clear Cache
$cacheCount = xcache_count(XC_TYPE_VAR);
for ($i = 0; $i < $cacheCount; $i++) {
if (@xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
$cleared = false;
break;
}
}
// Reset PHP_AUTH username/password
if ($tempUsername !== false) {
$_SERVER['PHP_AUTH_USER'] = $tempUsername;
} else {
unset($_SERVER['PHP_AUTH_USER']);
}
if ($tempPassword !== false) {
$_SERVER['PHP_AUTH_PW'] = $tempPassword;
} else {
unset($_SERVER['PHP_AUTH_PW']);
}
// Return result
return $cleared;
}
示例5: getAllActive
/**
* 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;
}
示例6: clear
public function clear()
{
if (!CACHE_STATUS) {
return false;
}
xcache_clear_cache(XC_TYPE_VAR, 0);
}
示例7: clear
/**
* {@inheritdoc}
*/
public function clear()
{
if (ini_get('xcache.admin.enable_auth')) {
throw new \BadMethodCallException('To use all features of \\Moust\\Silex\\Cache\\XcacheCache, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.');
}
return xcache_clear_cache(XC_TYPE_VAR, 0);
}
示例8: delete
public function delete($id, $tag = FALSE)
{
if ($tag !== FALSE) {
Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
return TRUE;
} elseif ($id !== TRUE) {
if (xcache_isset($id)) {
return xcache_unset($id);
}
return FALSE;
} else {
// Do the login
$this->auth();
$result = TRUE;
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
if (xcache_clear_cache(XC_TYPE_VAR, $i) !== NULL) {
$result = FALSE;
break;
}
}
// Undo the login
$this->auth(TRUE);
return $result;
}
return TRUE;
}
示例9: flush
/**
* @return bool
*/
public function flush()
{
$_SERVER["PHP_AUTH_USER"] = "xcache";
$_SERVER["PHP_AUTH_PW"] = "xcache";
xcache_clear_cache(XC_TYPE_VAR, 0);
return true;
}
示例10: tearDown
public function tearDown()
{
if (extension_loaded('xcache') && !ini_get('xcache.admin.enable_auth')) {
xcache_clear_cache(XC_TYPE_VAR);
}
$this->cacheDriver = null;
}
示例11: driver_clean
function driver_clean($option = array())
{
$cnt = xcache_count(XC_TYPE_VAR);
for ($i = 0; $i < $cnt; $i++) {
xcache_clear_cache(XC_TYPE_VAR, $i);
}
return true;
}
示例12: clean
/**
* Remove all keys and value from cache
*/
public function clean()
{
$cnt = xcache_count(XC_TYPE_VAR);
for ($i = 0; $i < $cnt; $i++) {
xcache_clear_cache(XC_TYPE_VAR, $i);
}
return true;
}
示例13: doFlush
/**
* {@inheritdoc}
*/
protected function doFlush()
{
$this->checkAuthorization();
xcache_clear_cache(XC_TYPE_VAR, 0);
return true;
}
示例14: flush
public function flush()
{
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
return false;
}
}
return true;
}
示例15: clear_cache
private function clear_cache()
{
$_SERVER["PHP_AUTH_USER"] = "xcache";
$_SERVER["PHP_AUTH_PW"] = "xcache";
$xcache_count = xcache_count(XC_TYPE_VAR);
for ($cacheid = 0; $cacheid < $xcache_count; $cacheid++) {
xcache_clear_cache(XC_TYPE_VAR, $cacheid);
}
}