Exemple #1
0
 public function clear()
 {
     if (!_cacheStatus) {
         return FALSE;
     }
     xcache_clear_cache(XC_TYPE_VAR, 0);
 }
 /**
  * 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);
             }
         };
     }
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 /**
  * {@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;
 }
 /**
  * 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;
 }
Exemple #6
0
 public function clear()
 {
     if (!CACHE_STATUS) {
         return false;
     }
     xcache_clear_cache(XC_TYPE_VAR, 0);
 }
 /**
  * {@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);
 }
 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;
 }
Exemple #9
0
 /**
  * @return bool
  */
 public function flush()
 {
     $_SERVER["PHP_AUTH_USER"] = "******";
     $_SERVER["PHP_AUTH_PW"] = "xcache";
     xcache_clear_cache(XC_TYPE_VAR, 0);
     return true;
 }
Exemple #10
0
 public function tearDown()
 {
     if (extension_loaded('xcache') && !ini_get('xcache.admin.enable_auth')) {
         xcache_clear_cache(XC_TYPE_VAR);
     }
     $this->cacheDriver = null;
 }
Exemple #11
0
 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;
 }
Exemple #12
0
 /**
  * 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;
 }
Exemple #13
0
 /**
  * {@inheritdoc}
  */
 protected function doFlush()
 {
     $this->checkAuthorization();
     
     xcache_clear_cache(XC_TYPE_VAR, 0);
     
     return true;
 }
Exemple #14
0
 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;
 }
Exemple #15
0
 private function clear_cache()
 {
     $_SERVER["PHP_AUTH_USER"] = "******";
     $_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);
     }
 }
Exemple #16
0
 public static function setUpBeforeClass()
 {
     if (!extension_loaded('xcache')) {
         static::$cache = null;
         return;
     }
     xcache_clear_cache(XC_TYPE_VAR);
     static::$cache = new \Cachalot\XcacheCache('cachalot-test:');
 }
Exemple #17
0
 /**
  * {@inheritdoc}
  */
 public function flush()
 {
     try {
         xcache_clear_cache();
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
 /**
  * Clear the userspace cache
  *
  * @return void
  */
 public function setUp()
 {
     for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
         if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
             return false;
         }
     }
     $this->XCache = new XCache();
 }
Exemple #19
0
 /**
  * {@inheritdoc}
  *
  * @return boolean
  */
 protected function doFlush()
 {
     if (ini_get('xcache.admin.enable_auth')) {
         // @codeCoverageIgnoreStart
         throw new \BadMethodCallException('You must set "xcache.admin.enable_auth" to "Off" in your php.ini to flush cache items.');
         // @codeCoverageIgnoreEnd
     }
     xcache_clear_cache(XC_TYPE_VAR, 0);
     return true;
 }
Exemple #20
0
function cs_cache_clear()
{
    $cache_count = xcache_count(XC_TYPE_VAR);
    for ($i = 0; $i < $cache_count; $i++) {
        xcache_clear_cache(XC_TYPE_VAR, $i);
    }
    $unicode = extension_loaded('unicode') ? 1 : 0;
    $where = "options_mod = 'clansphere' AND options_name = 'cache_unicode'";
    cs_sql_update(__FILE__, 'options', array('options_value'), array($unicode), 0, $where);
}
Exemple #21
0
 public function clear($prefix = '')
 {
     if (function_exists('xcache_unset_by_prefix')) {
         return xcache_unset_by_prefix($this->getNamespace() . $prefix);
     } else {
         // Since we can not clear by prefix, we just clear the whole cache.
         xcache_clear_cache(\XC_TYPE_VAR, 0);
     }
     return true;
 }
Exemple #22
0
 public function flush()
 {
     $count = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $count; $i++) {
         if (!xcache_clear_cache(XC_TYPE_VAR, $i)) {
             return FALSE;
         }
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
     return TRUE;
 }
Exemple #23
0
 /**
  * remove all cache-items
  *
  * @return bool
  */
 public function removeAll()
 {
     if (defined('XC_TYPE_VAR')) {
         $xCacheCount = xcache_count(XC_TYPE_VAR);
         for ($i = 0; $i < $xCacheCount; $i++) {
             xcache_clear_cache(XC_TYPE_VAR, $i);
         }
         return true;
     }
     return false;
 }
 /**
  */
 function flush()
 {
     if (!$this->is_ready()) {
         return null;
     }
     if ($this->_check_xcache_auth()) {
         xcache_clear_cache(XC_TYPE_VAR, 0);
         return true;
     }
     return null;
 }
Exemple #25
0
 /**
  * @inheritdoc
  */
 public function clean()
 {
     /** @noinspection PhpUndefinedConstantInspection */
     for ($i = 0, $cnt = xcache_count(XC_TYPE_VAR); $i < $cnt; $i++) {
         /** @noinspection PhpUndefinedConstantInspection */
         if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
             return false;
         }
     }
     return true;
 }
Exemple #26
0
 /**
  * Purge cache data
  *
  * @return null
  */
 function purge()
 {
     // Run before for XCache, if admin functions are disabled it will terminate execution
     parent::purge();
     // If the admin authentication is enabled but not set up, this will cause a nasty error.
     // Not much we can do about it though.
     $n = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $n; $i++) {
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
 }
Exemple #27
0
 public function clean()
 {
     $max_count = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $max_count; $i++) {
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
     $max_count = xcache_count(XC_TYPE_PHP);
     for ($i = 0; $i < $max_count; $i++) {
         xcache_clear_cache(XC_TYPE_PHP, $i);
     }
     return;
 }
 /**
  * @see sfCache
  */
 public function clean($mode = sfCache::ALL)
 {
     if ($mode !== sfCache::ALL) {
         return true;
     }
     $this->checkAuth();
     for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
         if (false === xcache_clear_cache(XC_TYPE_VAR, $i)) {
             return false;
         }
     }
     return true;
 }
Exemple #29
0
 /**
  * Xcache缓存-清空所有缓存
  * 不建议使用该功能
  * @return
  */
 public function clear_all()
 {
     $tmp['user'] = isset($_SERVER['PHP_AUTH_USER']) ? null : $_SERVER['PHP_AUTH_USER'];
     $tmp['pwd'] = isset($_SERVER['PHP_AUTH_PW']) ? null : $_SERVER['PHP_AUTH_PW'];
     $_SERVER['PHP_AUTH_USER'] = $this->authUser;
     $_SERVER['PHP_AUTH_PW'] = $this->authPwd;
     $max = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $max; $i++) {
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
     $_SERVER['PHP_AUTH_USER'] = $tmp['user'];
     $_SERVER['PHP_AUTH_PW'] = $tmp['pwd'];
     return true;
 }
 /**
  * Önbelleğe alınan tüm verileri siler
  *
  * @return mixed
  */
 public function flush()
 {
     $count = xcache_count(XC_TYPE_PHP);
     for ($i = 0; $i < $count; $i++) {
         // XCache PHP cache temizle.
         xcache_clear_cache(XC_TYPE_PHP, $i);
     }
     $count = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $count; $i++) {
         // XCache degisken cache temizle.
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
     return true;
 }