/** * {@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; }
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; }
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; }
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; }
/** * 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; }
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; }
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); } }
/** * 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(); }
/** * {@inheritDoc} */ public function getStats() { $size = 0; for ($ii = 0, $max = xcache_count(XC_TYPE_VAR); $ii < $max; ++$ii) { $block = xcache_list(XC_TYPE_VAR, $ii); foreach ($block as $entries) { $size += count($entries); } } return array(CacheInterface::STATS_SIZE => $size); }
/** * 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; }
/** * 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); } }
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; }
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; }
/** * 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; }
/** * @return array */ public function getCacheKeys() { $this->checkAuth(); $keys = array(); for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { $infos = xcache_list(XC_TYPE_VAR, $i); if (is_array($infos['cache_list'])) { foreach ($infos['cache_list'] as $info) { $keys[] = substr($info['name'], strlen($this->getOption('prefix'))); } } } return $keys; }
function cs_cache_info() { $form = array(); $cache_count = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $cache_count; $i++) { $info = xcache_list(XC_TYPE_VAR, $i); foreach ($info['cache_list'] as $num => $data) { $handle = $data['name'] . ' (' . $i . '.' . $num . ')'; $form[$handle] = array('name' => $handle, 'time' => $data['ctime'], 'size' => $data['size']); } } ksort($form); return array_values($form); }
/** * Ö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; }
/** * {@inheritdoc} */ public function getIds() { $this->_checkAuth(); $keys = array(); for ($i = 0, $count = xcache_count(XC_TYPE_VAR); $i < $count; $i++) { $entries = xcache_list(XC_TYPE_VAR, $i); if (is_array($entries['cache_list'])) { foreach ($entries['cache_list'] as $entry) { $keys[] = $entry['name']; } } } return $keys; }
public function clear($name = null) { if (function_exists('xcache_clear_cache') && function_exists('xcache_count')) { $count = xcache_count(XC_TYPE_PHP); for ($cache_id = 0; $cache_id < $count; $cache_id++) { xcache_clear_cache(XC_TYPE_PHP, $cache_id); } } if ($name === null) { $this->data = array(); } else { unset($this->data[$name]); } $this->save(); }
/** * {@inheritdoc} */ public function flush() { $backup = ['PHP_AUTH_USER' => !empty($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '', 'PHP_AUTH_PW' => !empty($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '']; $auth = ['PHP_AUTH_USER' => $this->getConfig('username'), 'PHP_AUTH_PW' => $this->getConfig('password')]; // Set auth $_SERVER = $auth + $_SERVER; // Clear cache $count = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $count; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } // Reset auth $_SERVER = $backup + $_SERVER; return true; }
public function delete($id) { // 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; }
function getCacheInfos() { $phpCacheCount = xcache_count(XC_TYPE_PHP); $varCacheCount = xcache_count(XC_TYPE_VAR); $cacheInfos = array(); for ($i = 0; $i < $phpCacheCount; $i++) { $cacheInfo = xcache_info(XC_TYPE_PHP, $i); $cacheInfo['type'] = XC_TYPE_PHP; $cacheInfos[] = $cacheInfo; } for ($i = 0; $i < $varCacheCount; $i++) { $cacheInfo = xcache_info(XC_TYPE_VAR, $i); $cacheInfo['type'] = XC_TYPE_VAR; $cacheInfos[] = $cacheInfo; } return $cacheInfos; }
/** * {@inheritDoc} */ public function clear() { $this->lastModified = time(); // iterate over all entries and match the group prefix $groupPrefix = $this->group . '/'; for ($ii = 0, $max = xcache_count(XC_TYPE_VAR); $ii < $max; ++$ii) { $block = xcache_list(XC_TYPE_VAR, $ii); foreach ($block as $entries) { foreach ($entries as $entry) { if (0 === strpos($entry['name'], $groupPrefix)) { xcache_unset($entry['name']); } } } } return true; }
/** * (non-PHPdoc) * @see Cache::clear() */ public function clear() { // xcache_clear_cache需要验证权限 $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->auth_user; $_SERVER['PHP_AUTH_PW'] = $this->auth_pwd; // 如果配置中xcache.var_count > 0 则不能用xcache_clear_cache(XC_TYPE_VAR, 0)的方式删除 $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; }
/** * Flush the cache. */ function flush() { $prefix = INDEX_FILE_LOCATION . ':' . $this->getContext() . ':' . $this->getCacheId(); if (function_exists('xcache_unset_by_prefix')) { // If possible, just flush the context xcache_unset_by_prefix(prefix); } else { // Otherwise, we need to do this manually for ($i = 0; $i < xcache_count(XC_TYPE_VAR); $i++) { $cache = xcache_list(XC_TYPE_VAR, $i); foreach ($cache['cache_list'] as $entry) { if (substr($entry['name'], 0, strlen($prefix)) == $prefix) { xcache_unset($entry['name']); } } } } }
function get_data() { $pcnt = xcache_count(XC_TYPE_PHP); $vcnt = xcache_count(XC_TYPE_VAR); $info['php_max'] = 0; $info['php_cur'] = 0; $info['var_max'] = 0; $info['var_cur'] = 0; $info['php_hits'] = 0; $info['var_hits'] = 0; $info['php_miss'] = 0; $info['var_miss'] = 0; $info['php_cached'] = 0; $info['var_cached'] = 0; $info['php_errors'] = 0; $info['var_errors'] = 0; $cacheInfos = array(); for ($i = 0; $i < $pcnt; $i++) { $data = xcache_info(XC_TYPE_PHP, $i); $info['php_max'] += $data["size"]; $info['php_cur'] += $data["avail"]; $info['php_hits'] += $data["hits"]; $info['php_miss'] += $data["misses"]; $info['php_cached'] += $data["cached"]; $info['php_errors'] += $data["errors"]; } for ($i = 0; $i < $vcnt; $i++) { $data = xcache_info(XC_TYPE_VAR, $i); $info['var_max'] += $data["size"]; $info['var_cur'] += $data["avail"]; $info['var_hits'] += $data["hits"]; $info['var_miss'] += $data["misses"]; $info['var_cached'] += $data["cached"]; $info['var_errors'] += $data["errors"]; } return $info; }
public function getCacheInfo($key) { $this->checkAuth(); for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { $infos = xcache_list(XC_TYPE_VAR, $i); if (is_array($infos['cache_list'])) { foreach ($infos['cache_list'] as $info) { if ($this->getOption('prefix') . $key == $info['name']) { return $info; } } } } return null; }
/** * Clean some cache records * * Available modes are : * 'all' (default) => remove all cache entries ($tags is not used) * 'old' => unsupported * 'matchingTag' => unsupported * 'notMatchingTag' => unsupported * 'matchingAnyTag' => unsupported * * @param string $mode clean mode * @param array $tags array of tags * @throws Zend_Cache_Exception * @return boolean true if no problem */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case Zend_Cache::CLEANING_MODE_ALL: // Necessary because xcache_clear_cache() need basic authentification $backup = array(); if (isset($_SERVER['PHP_AUTH_USER'])) { $backup['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER']; } if (isset($_SERVER['PHP_AUTH_PW'])) { $backup['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW']; } if ($this->_options['user']) { $_SERVER['PHP_AUTH_USER'] = $this->_options['user']; } if ($this->_options['password']) { $_SERVER['PHP_AUTH_PW'] = $this->_options['password']; } $cnt = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $cnt; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } if (isset($backup['PHP_AUTH_USER'])) { $_SERVER['PHP_AUTH_USER'] = $backup['PHP_AUTH_USER']; $_SERVER['PHP_AUTH_PW'] = $backup['PHP_AUTH_PW']; } return true; break; case Zend_Cache::CLEANING_MODE_OLD: $this->_log("Zend_Cache_Backend_Xcache::clean() : CLEANING_MODE_OLD is unsupported by the Xcache backend"); break; case Zend_Cache::CLEANING_MODE_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND); break; default: Zend_Cache::throwException('Invalid mode for clean() method'); break; } }
/** * Delete all keys from the cache * * @param bool $check If true no deletes will occur and instead CakePHP will rely * on key TTL values. * @return bool True if the cache was successfully cleared, false otherwise */ public function clear($check) { $this->_auth(); $max = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $max; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } $this->_auth(true); return true; }
/** * Save the local configuration file */ public function save() { if ($this->strTop == '') { $this->strTop = '<?php'; } $strFile = trim($this->strTop) . "\n\n"; $strFile .= "### INSTALL SCRIPT START ###\n"; foreach ($this->arrData as $k => $v) { $strFile .= "{$k} = {$v}\n"; } $strFile .= "### INSTALL SCRIPT STOP ###\n"; $this->strBottom = trim($this->strBottom); if ($this->strBottom != '') { $strFile .= "\n" . $this->strBottom . "\n"; } $strTemp = md5(uniqid(mt_rand(), true)); // Write to a temp file first $objFile = fopen(TL_ROOT . '/system/tmp/' . $strTemp, 'wb'); fputs($objFile, $strFile); fclose($objFile); // Make sure the file has been written (see #4483) if (!filesize(TL_ROOT . '/system/tmp/' . $strTemp)) { \System::log('The local configuration file could not be written. Have your reached your quota limit?', __METHOD__, TL_ERROR); return; } // Then move the file to its final destination $this->Files->rename('system/tmp/' . $strTemp, 'system/config/localconfig.php'); // Reset the Zend OPcache if (function_exists('opcache_invalidate')) { opcache_invalidate(TL_ROOT . '/system/config/localconfig.php', true); } // Reset the Zend Optimizer+ cache (unfortunately no API to delete just a single file) if (function_exists('accelerator_reset')) { accelerator_reset(); } // Recompile the APC file (thanks to Trenker) if (function_exists('apc_compile_file') && !ini_get('apc.stat')) { apc_compile_file(TL_ROOT . '/system/config/localconfig.php'); } // Purge the eAccelerator cache (thanks to Trenker) if (function_exists('eaccelerator_purge') && !ini_get('eaccelerator.check_mtime')) { @eaccelerator_purge(); } // Purge the XCache cache (thanks to Trenker) if (function_exists('xcache_count') && !ini_get('xcache.stat')) { if (($count = xcache_count(XC_TYPE_PHP)) > 0) { for ($id = 0; $id < $count; $id++) { xcache_clear_cache(XC_TYPE_PHP, $id); } } } }