예제 #1
0
파일: xcache.php 프로젝트: kvox/TVSS
 function driver_stats($option = array())
 {
     $res = array("info" => "", "size" => "", "data" => "");
     try {
         $res['data'] = xcache_list(XC_TYPE_VAR, 100);
     } catch (Exception $e) {
         $res['data'] = array();
     }
     return $res;
 }
예제 #2
0
 /**
  * {@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);
 }
예제 #3
0
파일: xcache.php 프로젝트: vanie3/appland
 public function clean($group, $mode = null)
 {
     $allinfo = xcache_list(XC_TYPE_VAR, 0);
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (strpos($key['name'], $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group') {
             xcache_unset($key['name']);
         }
     }
     return true;
 }
예제 #4
0
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);
}
 /**
  * @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;
 }
예제 #6
0
 /**
  * {@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;
 }
예제 #7
0
 /**
  * {@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;
 }
예제 #8
0
 /**
  * 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']);
                 }
             }
         }
     }
 }
예제 #9
0
 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;
 }
예제 #10
0
 /**
  * @param array $option
  * @return array
  */
 public function driver_stats($option = array())
 {
     $res = array('info' => '', 'size' => '', 'data' => '');
     try {
         $res['data'] = xcache_list(XC_TYPE_VAR, 100);
     } catch (Exception $e) {
         $res['data'] = array();
     }
     return $res;
 }
예제 #11
0
 /**
  * Clean cache for a group given a mode.
  *
  * group mode		: cleans all cache in the group
  * notgroup mode	: cleans all cache not in the group
  *
  * @access	public
  * @param	string	$group	The cache data group
  * @param	string	$mode	The mode for cleaning cache [group|notgroup]
  * @return	boolean	True on success, false otherwise
  * @since	1.5
  */
 function clean($group, $mode)
 {
     if (!ini_get('xcache.admin.enable_auth')) {
         $allinfo = xcache_list(XC_TYPE_VAR, 0);
         $keys = $allinfo['cache_list'];
         $secret = $this->_hash;
         foreach ($keys as $key) {
             if (strpos($key['name'], $secret . '-cache-' . $group . '-' . $this->_site) === 0 xor $mode != 'group') {
                 xcache_unset($key['name']);
             }
         }
         return true;
     }
     return false;
 }
예제 #12
0
 /**
  * Get metadata of an item.
  *
  * @param  string $normalizedKey
  * @return array|bool Metadata on success, false on failure
  * @throws Exception\ExceptionInterface
  */
 protected function internalGetMetadata(&$normalizedKey)
 {
     $options = $this->getOptions();
     $namespace = $options->getNamespace();
     $prefix = $namespace === '' ? '' : $namespace . $options->getNamespaceSeparator();
     $internalKey = $prefix . $normalizedKey;
     if (xcache_isset($internalKey)) {
         $this->initAdminAuth();
         $cnt = xcache_count(XC_TYPE_VAR);
         for ($i = 0; $i < $cnt; $i++) {
             $list = xcache_list(XC_TYPE_VAR, $i);
             foreach ($list['cache_list'] as &$metadata) {
                 if ($metadata['name'] === $internalKey) {
                     $this->normalizeMetadata($metadata);
                     return $metadata;
                 }
             }
         }
         $this->resetAdminAuth();
     }
     return false;
 }
예제 #13
0
 /**
  * Get all the cache ids
  *
  * @return array
  */
 public function getIDs()
 {
     if (empty($this->_ids)) {
         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) {
                     $this->_ids[] = str_replace(array($this->_prefix, $this->_suffix), '', $entry['name']);
                 }
             }
         }
     }
     return $this->_ids;
 }
예제 #14
0
 /**
  * Clean cache for a group provided.
  *
  * @param   string $group The cache data group, passed '*' indicate all cache removal
  *
  * @return  boolean
  *
  * @since   1.2.7
  */
 public function clean($group)
 {
     $group = trim($group);
     if (!$group) {
         return false;
     }
     $cache_info = xcache_list(XC_TYPE_VAR, 0);
     $keys = $cache_info['cache_list'];
     foreach ($keys as $key) {
         if ($group == '*' || strpos($key['name'], $this->secret . '-cache-' . $group . '.') === 0) {
             xcache_unset($key['name']);
         }
     }
     return true;
 }
예제 #15
0
 /**
  * Get all cached data
  *
  * This requires the php.ini setting xcache.admin.enable_auth = Off.
  *
  * @return  array
  */
 public function all()
 {
     $hash = $this->options['hash'];
     $allinfo = xcache_list(XC_TYPE_VAR, 0);
     $data = array();
     foreach ($allinfo['cache_list'] as $key) {
         $namearr = explode('-', $key['name']);
         if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache') {
             $group = $namearr[2];
             if (!isset($data[$group])) {
                 $item = new Auditor($group);
             } else {
                 $item = $data[$group];
             }
             $item->tally($key['size'] / 1024);
             $data[$group] = $item;
         }
     }
     return $data;
 }
예제 #16
0
 /**
  * Clean cache for a group given a mode.
  *
  * This requires the php.ini setting xcache.admin.enable_auth = Off.
  *
  * @param   string  $group  The cache data group
  * @param   string  $mode   The mode for cleaning cache [group|notgroup]
  * group mode  : cleans all cache in the group
  * notgroup mode  : cleans all cache not in the group
  *
  * @return  boolean  True on success, false otherwise
  *
  * @since   11.1
  */
 public function clean($group, $mode = null)
 {
     // Make sure XCache is configured properly
     if (self::isSupported() == false) {
         return true;
     }
     $allinfo = xcache_list(XC_TYPE_VAR, 0);
     $keys = $allinfo['cache_list'];
     $secret = $this->_hash;
     foreach ($keys as $key) {
         if (strpos($key['name'], $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group') {
             xcache_unset($key['name']);
         }
     }
     return true;
 }
예제 #17
0
파일: xcache.php 프로젝트: gggeek/ggsysinfo
 // {{{ load info/list
 $cacheinfos = array();
 for ($i = 0; $i < $pcnt; $i++) {
     $data = xcache_info(XC_TYPE_PHP, $i);
     if ($type === XC_TYPE_PHP) {
         $data += xcache_list(XC_TYPE_PHP, $i);
     }
     $data['type'] = XC_TYPE_PHP;
     $data['cache_name'] = "php#{$i}";
     $data['cacheid'] = $i;
     $cacheinfos[] = $data;
 }
 for ($i = 0; $i < $vcnt; $i++) {
     $data = xcache_info(XC_TYPE_VAR, $i);
     if ($type === XC_TYPE_VAR) {
         $data += xcache_list(XC_TYPE_VAR, $i);
     }
     $data['type'] = XC_TYPE_VAR;
     $data['cache_name'] = "var#{$i}";
     $data['cacheid'] = $i;
     $cacheinfos[] = $data;
 }
 // }}}
 // {{{ merge the list
 switch ($type) {
     case XC_TYPE_PHP:
     case XC_TYPE_VAR:
         $cachelist = array('type' => $type, 'cache_list' => array(), 'deleted_list' => array());
         if ($type == XC_TYPE_VAR) {
             $cachelist['type_name'] = 'var';
         } else {
예제 #18
0
function getCacheInfos()
{
    static $cacheInfos;
    if (isset($cacheInfos)) {
        return $cacheInfos;
    }
    $phpCacheCount = xcache_count(XC_TYPE_PHP);
    $varCacheCount = xcache_count(XC_TYPE_VAR);
    $cacheInfos = array();
    $total = array();
    global $maxHitsByHour;
    $maxHitsByHour = array(0, 0);
    for ($i = 0; $i < $phpCacheCount; $i++) {
        $data = xcache_info(XC_TYPE_PHP, $i);
        if ($_GET['do'] === 'listphp') {
            $data += xcache_list(XC_TYPE_PHP, $i);
        }
        $data['type'] = XC_TYPE_PHP;
        $data['cache_name'] = "php#{$i}";
        $data['cacheid'] = $i;
        $cacheInfos[] = $data;
        $maxHitsByHour[XC_TYPE_PHP] = max($maxHitsByHour[XC_TYPE_PHP], max($data['hits_by_hour']));
        if ($phpCacheCount >= 2) {
            calc_total($total, $data);
        }
    }
    if ($phpCacheCount >= 2) {
        $total['type'] = XC_TYPE_PHP;
        $total['cache_name'] = _T('Total');
        $total['cacheid'] = -1;
        $total['gc'] = null;
        $total['istotal'] = true;
        unset($total['compiling']);
        $cacheInfos[] = $total;
    }
    $total = array();
    for ($i = 0; $i < $varCacheCount; $i++) {
        $data = xcache_info(XC_TYPE_VAR, $i);
        if ($_GET['do'] === 'listvar') {
            $data += xcache_list(XC_TYPE_VAR, $i);
        }
        $data['type'] = XC_TYPE_VAR;
        $data['cache_name'] = "var#{$i}";
        $data['cacheid'] = $i;
        $cacheInfos[] = $data;
        $maxHitsByHour[XC_TYPE_VAR] = max($maxHitsByHour[XC_TYPE_VAR], max($data['hits_by_hour']));
        if ($varCacheCount >= 2) {
            calc_total($total, $data);
        }
    }
    if ($varCacheCount >= 2) {
        $total['type'] = XC_TYPE_VAR;
        $total['cache_name'] = _T('Total');
        $total['cacheid'] = -1;
        $total['gc'] = null;
        $total['istotal'] = true;
        $cacheInfos[] = $total;
    }
    return $cacheInfos;
}
예제 #19
0
         return xcache_set($name, $value, $time_in_second);
     }
     return false;
 }
 private static function xcache_get($name)
 {
     $name = self::getMemoryName($name);
     $data = xcache_get($name);