Example #1
0
 /**
  * Purge cache data
  *
  * @return void
  */
 function purge()
 {
     foreach (eaccelerator_list_keys() as $var) {
         // @todo Check why the substr()
         // @todo Only unset vars matching $this->key_prefix
         eaccelerator_rm(substr($var['name'], 1));
     }
     parent::purge();
 }
 public function flush()
 {
     $v9b207167e5381c47682c6b4f58a623fb = eaccelerator_clear();
     $v14f802e1fba977727845e8872c1743a7 = eaccelerator_list_keys();
     foreach ($v14f802e1fba977727845e8872c1743a7 as $v3c6e0b8a9c15224a8228b9a98ca1531d) {
         eaccelerator_rm(substr($v3c6e0b8a9c15224a8228b9a98ca1531d['name'], 1));
     }
     return $v9b207167e5381c47682c6b4f58a623fb;
 }
 /**
  * Deletes all EAccelerator data cache
  */
 public function flushAll()
 {
     //delete expired content then delete all
     eaccelerator_gc();
     $idkeys = eaccelerator_list_keys();
     foreach ($idkeys as $k) {
         $this->flush(substr($k['name'], 1));
     }
 }
Example #4
0
 /**
  * 清空cache中所有项, 全部清除需要遍历cache,一个一个删除!
  * @return void
  * @access public
  */
 public static function flush()
 {
     // 清除过期的key
     eaccelerator_gc();
     // 遍历key,一个一个删除
     $list = eaccelerator_list_keys();
     foreach ($list as $k => $v) {
         self::delete($v['name']);
     }
 }
Example #5
0
 public function flush()
 {
     // first, remove expired content from cache
     eaccelerator_gc();
     // now, remove leftover cache-keys
     $keys = eaccelerator_list_keys();
     foreach ($keys as $key) {
         $this->deleteValue(substr($key['name'], 1));
     }
 }
 /**
  * remove all data from cache by key prefix
  * @return true on success
  */
 function removeAllByPrefix($s)
 {
     $l = strlen($s);
     $aKeys = eaccelerator_list_keys();
     foreach ($aKeys as $aKey) {
         $sKey = 0 === strpos($aKey['name'], ':') ? substr($aKey['name'], 1) : $aKey['name'];
         if (0 == strncmp($sKey, $s, $l)) {
             $this->delData($sKey);
         }
     }
     return true;
 }
 /**
  * @return array
  */
 public function getCacheKeys()
 {
     $infos = eaccelerator_list_keys();
     if (!is_array($infos)) {
         return null;
     }
     $keys = array();
     foreach ($infos as $info) {
         $keys[] = substr($info['name'], strlen($this->getOption('prefix')));
     }
     return $keys;
 }
Example #8
0
 public function clean($group, $mode = null)
 {
     $keys = eaccelerator_list_keys();
     $secret = $this->_hash;
     if (is_array($keys)) {
         foreach ($keys as $key) {
             $key['name'] = ltrim($key['name'], ':');
             if (strpos($key['name'], $secret . '-cache-' . $group . '-') === 0 xor $mode != 'group') {
                 eaccelerator_rm($key['name']);
             }
         }
     }
     return true;
 }
 function destroy_all()
 {
     if (!function_exists('eaccelerator_list_keys')) {
         return;
     }
     $key_list = eaccelerator_list_keys();
     $key_length = strlen($this->key);
     foreach ($key_list as $key) {
         if (strpos($key['name'], $this->key) === 0) {
             eaccelerator_rm($key['name']);
             $this->remove(substr($key['name'], $key_length));
         }
     }
     $this->reset();
 }
 /**
  * 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)
 {
     $keys = eaccelerator_list_keys();
     $secret = $this->_hash;
     if (is_array($keys)) {
         foreach ($keys as $key) {
             /* Trim leading ":" to work around list_keys namespace bug in eAcc. This will still work when bug is fixed */
             $key['name'] = ltrim($key['name'], ':');
             if (strpos($key['name'], $secret . '-cache-' . $group . '-' . $this->_site) === 0 xor $mode != 'group') {
                 eaccelerator_rm($key['name']);
             }
         }
     }
     return true;
 }
Example #11
0
 public function info()
 {
     $info = array();
     $info['info'] = eaccelerator_info();
     $info['keys'] = eaccelerator_list_keys();
     $info['script'] = eaccelerator_cached_scripts();
     $info['script_remove'] = eaccelerator_removed_scripts();
     return $info;
 }
Example #12
0
 /**
  *  Get stats and usage Informations for display from eAccelerator
  */
 public function stats()
 {
     // get info Get info about eAccelerator
     $eac_sysinfos['infos'] = eaccelerator_info();
     // List cached keys
     $keys = eaccelerator_list_keys();
     if (is_array($keys)) {
         foreach ($keys as $key) {
             $eac_sysinfo['keys'][] = $key;
         }
     }
     return null;
 }
Example #13
0
        print "<tr " . $bc[$var] . ">";
        print "<td>Purge cache</td>";
        print '<td align="right"><input type="submit" class="butAction" name="purge" value="purge" title="remove all \'removed\' scripts from shared memory" /></td>';
        print "</tr></table></form>";
    }
    if (is_array($resCached)) {
        print "<br><br>";
        print "<b>Cached scripts</b><br>";
        create_script_table($resCached);
    }
    if (is_array($resRemoved)) {
        print "<br><br>";
        print "<b>Removed scripts</b><br>";
        create_script_table($resRemoved);
    }
} else {
    print "<br><br>";
    print "Check in your <b>php.ini</b> that <b>eaccelerator.allowed_admin_path</b> parameter is : ";
    print "<br><br>";
    print "<b>" . $_SERVER["SCRIPT_FILENAME"] . "</b>";
    print "<br><br>";
}
if (function_exists('eaccelerator_get')) {
    print '<br><br>';
    print '<b>Cached keys</b><br>';
    $res = eaccelerator_list_keys();
    create_key_table($res);
}
print "<br><br>";
llxFooter();
$db->close();
Example #14
0
<!-- }}} -->

<h2>Cached scripts</h2>
<?php 
create_script_table(eaccelerator_cached_scripts());
?>

<h2>Removed scripts</h2>
<?php 
create_script_table(eaccelerator_removed_scripts());
?>

<?php 
if (function_exists('eaccelerator_get')) {
    echo "<h2>Cached keys</h2>";
    create_key_table(eaccelerator_list_keys());
}
?>

<!-- {{{ footer -->
<br /><br />
<table>
    <tr><td class="center">
    <a href="http://eaccelerator.net"><img src="?=<?php 
echo $info['logo'];
?>
" alt="eA logo" /></a>
    <strong>Created by the eAccelerator team, <a href="http://eaccelerator.net">http://eaccelerator.net</a></strong><br /><br />
    <nobr>eAccelerator <?php 
echo $info['version'];
?>
 /**
  * {@inheritdoc}
  */
 public function getIds()
 {
     return eaccelerator_list_keys();
 }
Example #16
0
 /**
  * Return an array of stored cache ids
  *
  * @return string[] array of stored cache ids (string)
  */
 public function getIds()
 {
     $res = array();
     $array = eaccelerator_list_keys();
     foreach ($array as $key => $info) {
         $res[] = $key;
     }
     return $res;
 }
Example #17
0
 /**
  * Get all cached data
  *
  * @return  array
  */
 public function getAll()
 {
     $keys = eaccelerator_list_keys();
     $hash = $this->options['hash'];
     $data = array();
     foreach ($keys as $key) {
         // Trim leading ":" to work around list_keys namespace bug in eAcc.
         // This will still work when bug is fixed.
         $name = ltrim($key['name'], ':');
         $namearr = explode('-', $name);
         if ($namearr !== false && $namearr[0] == $hash && $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;
 }
Example #18
0
	/**
	 * Delete all keys from the cache
	 *
	 * @param boolean $check if true will check expiration, otherwise delete all
	 * @return boolean true if the cache was succesfully cleared, false otherwise
	 * @access public
	 */
    function clear($check) { 
        $result = true; 
        $keys = eaccelerator_list_keys(); 

        foreach ($keys as $key) { 
            $result = $this->delete($key['name']) && $result; 
        } 
        if ($check) { 
            return $this->gc(); 
        } 
         
        return $result; 
    } 
 /**
  * Clears the cache.
  *
  * @return boolean true if ok, false otherwise
  */
 public static function clear()
 {
     switch (self::cacher()) {
         case 'apc':
             return apc_clear_cache('user');
         case 'xcache':
             for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
                 if (!xcache_clear_cache(XC_TYPE_VAR, $i)) {
                     return false;
                 }
             }
             return true;
         case 'eaccelerator':
             $infos = eaccelerator_list_keys();
             if (is_array($infos)) {
                 foreach ($infos as $info) {
                     // eaccelerator bug (http://eaccelerator.net/ticket/287)
                     $key = 0 === strpos($info['name'], ':') ? substr($info['name'], 1) : $info['name'];
                     if (!eaccelerator_rm($key)) {
                         return false;
                     }
                 }
             }
             return true;
     }
     return false;
 }
Example #20
0
 /**
  * Clean expired cache.
  * Note : \Hoa\Cache::CLEAN_USER is not supported, it's reserved for APC
  * backend.
  *
  * @param   int  $lifetime    Lifetime of caches.
  * @return  void
  * @throws  \Hoa\Cache\Exception
  */
 public function clean($lifetime = Cache::CLEAN_EXPIRED)
 {
     switch ($lifetime) {
         case Cache::CLEAN_ALL:
             $infos = eaccelerator_list_keys();
             // EAccelerator bug (http://eaccelerator.net/ticket/287).
             foreach ($infos as $foo => $info) {
                 $key = 0 === strpos($info['name'], ':') ? substr($info['name'], 1) : $info['name'];
                 if (false === eaccelerator_rm($key)) {
                     throw new \Hoa\Cache\Exception('Remove all existing cache file failed ' . '(maybe for the %s cache).', 1, $key);
                 }
             }
             break;
         case Cache::CLEAN_EXPIRED:
             // Manage by EAccelerator.
             break;
         case Cache::CLEAN_USER:
             throw new \Hoa\Cache\Exception('\\Hoa\\Cache::CLEAN_USER constant is not supported by ' . 'EAccelerator backend.', 2);
     }
     return;
 }
function eaccelerator_display($mode, $start = 0, $limit = 5, $sort = false)
{
    global $_CLASS, $sort_by;
    $total_count = 0;
    switch ($mode) {
        case 'scripts':
        case 'removed_scripts':
            $scripts_array = $mode === 'scripts' ? eaccelerator_cached_scripts() : eaccelerator_removed_scripts();
            if (!empty($scripts_array)) {
                $sort_by = 'mtime';
                usort($scripts_array, 'eaccelerator_compare');
                $total_count = count($scripts_array);
                $end = min($start + $limit, $total_count);
                for ($i = $start; $i < $end; $i++) {
                    $scripts_array[$i]['time'] = date('Y/m/d H:i', $scripts_array[$i]['mtime']);
                    $scripts_array[$i]['size'] = generate_size($scripts_array[$i]['size']);
                    $_CLASS['core_template']->assign_vars_array($mode . '_array', $scripts_array[$i]);
                }
            }
            break;
        case 'keys':
            $keys_array = eaccelerator_list_keys();
            if (!empty($keys_array)) {
                $sort_by = 'created';
                usort($keys_array, 'eaccelerator_compare');
                $total_count = count($keys_array);
                $end = min($start + $limit, $total_count);
                for ($i = $start; $i < $end; $i++) {
                    $keys_array[$i]['created'] = date('Y/m/d H:i', $keys_array[$i]['created']);
                    $keys_array[$i]['size'] = generate_size($keys_array[$i]['size']);
                    if ($keys_array[$i]['ttl'] == 0) {
                        $keys_array[$i]['expire_time'] = 'none';
                    } elseif ($keys_array[$i]['ttl'] == -1) {
                        $keys_array[$i]['expire_time'] = 'expired';
                    } else {
                        $keys_array[$i]['expire_time'] = date('Y/m/d H:i', $keys_array[$i]['ttl']);
                    }
                    $_CLASS['core_template']->assign_vars_array('keys_array', $keys_array[$i]);
                }
            }
            break;
    }
    $pagination = generate_pagination('eaccelerator&amp;mode=' . $mode, $total_count, $limit, $start, true);
    $_CLASS['core_template']->assign_array(array($mode . '_more' => $total_count < $limit ? false : true, $mode . '_pagination' => $pagination['formated'], $mode . '_pagination_array' => $pagination['array']));
}
Example #22
0
 public function exists($key)
 {
     return CACHE_STATUS ? in_array($key, eaccelerator_list_keys()) : false;
 }
Example #23
0
 function stats()
 {
     return eaccelerator_list_keys();
 }
Example #24
0
 /**
  *  Get stats and usage Informations for display from eAccelerator.
  */
 public function stats()
 {
     $infos = [];
     $infos['infos'] = eaccelerator_info();
     $keys = eaccelerator_list_keys();
     if (is_array($keys)) {
         foreach ($keys as $key) {
             $infos['keys'][] = $key;
         }
     }
     return $infos;
 }
 protected function getCacheInfo($key)
 {
     $infos = eaccelerator_list_keys();
     if (is_array($infos)) {
         foreach ($infos as $info) {
             if ($this->getOption('prefix') . $key == $info['name']) {
                 return $info;
             }
         }
     }
     return null;
 }
 /**
  * get size of cached data by name prefix
  */
 function getSizeByPrefix($s)
 {
     $iSize = 0;
     $l = strlen($s);
     $aKeys = eaccelerator_list_keys();
     foreach ($aKeys as $aKey) {
         $sKey = 0 === strpos($aKey['name'], ':') ? substr($aKey['name'], 1) : $aKey['name'];
         if (0 == strncmp($sKey, $s, $l)) {
             $iSize += strlen($this->getData($sKey));
         }
     }
     return $iSize;
 }
Example #27
0
 public function exists($key)
 {
     return _cacheStatus ? in_array($key, eaccelerator_list_keys()) : FALSE;
 }
Example #28
0
 /**
  * Get list of all sessions
  * 
  * @param   array  $filters
  * @return  array
  */
 public function all($filters = array())
 {
     $keys = eaccelerator_list_keys();
     $data = array();
     if (is_array($keys)) {
         foreach ($keys as $key) {
             // Trim leading ":" to work around list_keys namespace bug in eAcc.
             // This will still work when bug is fixed.
             $key['name'] = ltrim($key['name'], ':');
             if (strpos($key['name'], $this->prefix) === 0) {
                 continue;
             }
             $session = new Object();
             $session->session_id = $file->getName();
             $session->data = (string) eaccelerator_get($key['name']);
             $data[] = $session;
         }
     }
     return $data;
 }
 /**
  * Immediately invalidates all keys in the cache store
  *
  * Whether or not the cache store's memory or resource allocation is freed
  * is determined by the implementation
  *
  * @return boolean True on success, false on failure
  */
 public function expireAll()
 {
     if (!$this->enabled) {
         return true;
     }
     $this->Logger->debug('Expire all keys');
     $ns = ini_get('eaccelerator.name_space');
     foreach (eaccelerator_list_keys() as $key => $value) {
         eaccelerator_rm(StringUtils::strRight($value['name'], $ns . ':'));
     }
 }