本文整理汇总了PHP中xcache_count函数的典型用法代码示例。如果您正苦于以下问题:PHP xcache_count函数的具体用法?PHP xcache_count怎么用?PHP xcache_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xcache_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例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: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
}
示例8: setUp
/**
* 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();
}
示例9: getStats
/**
* {@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);
}
示例10: removeAll
/**
* 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;
}
示例11: purge
/**
* 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);
}
}
示例12: flush
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;
}
示例13: clean
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;
}
示例14: clear_all
/**
* 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;
}
示例15: getCacheKeys
/**
* @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;
}