当前位置: 首页>>代码示例>>PHP>>正文


PHP Memcache::getStats方法代码示例

本文整理汇总了PHP中Memcache::getStats方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::getStats方法的具体用法?PHP Memcache::getStats怎么用?PHP Memcache::getStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcache的用法示例。


在下文中一共展示了Memcache::getStats方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Memcache

<?php

$memcache = new Memcache();
$memcache->connect('localhost', 11211);
$version = $memcache->getVersion();
echo "Server's version: " . $version . "\n";
print_r($memcache->getStats());
开发者ID:xianhuazhou,项目名称:small-ideas,代码行数:7,代码来源:memcache_stats.php

示例2: __construct

 public function __construct()
 {
     $this->connect();
     // Get keys (this code comes from Doctrine 2 project)
     $this->keys = array();
     $servers = self::getMemcachedServers();
     if (is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats')) {
         $all_slabs = $this->memcache->getStats('slabs');
     }
     if (isset($all_slabs) && is_array($all_slabs)) {
         foreach ($all_slabs as $server => $slabs) {
             if (is_array($slabs)) {
                 foreach (array_keys($slabs) as $slab_id) {
                     if (is_int($slab_id)) {
                         $dump = $this->memcache->getStats('cachedump', (int) $slab_id);
                         if ($dump) {
                             foreach ($dump as $entries) {
                                 if ($entries) {
                                     $this->keys = array_merge($this->keys, array_keys($entries));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:28,代码来源:CacheMemcache.php

示例3: status

 /**
  * @inheritdoc
  */
 public function status()
 {
     $stats = $this->memcache->getStats();
     $status[self::HITS] = isset($stats['get_hits']) ? $stats['get_hits'] : 0;
     $status[self::MISSES] = isset($stats['get_misses']) ? $stats['get_misses'] : 0;
     $status[self::START_TIME] = isset($stats['uptime']) ? $stats['uptime'] : 0;
     $status[self::MEMORY_USED] = isset($stats['bytes']) ? $stats['bytes'] : 0;
     $status[self::MEMORY_LEFT] = isset($stats['limit_maxbytes']) ? $stats['limit_maxbytes'] : 0;
     return $status;
 }
开发者ID:lixiongyou,项目名称:pudding,代码行数:13,代码来源:Memcache.php

示例4: max_packet_size

 /**
  * Determine the maximum size for cache data to be written
  */
 private function max_packet_size()
 {
     if ($this->max_packet < 0) {
         $this->max_packet = 2097152;
         // default/max is 2 MB
         if ($this->type == 'db') {
             if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) {
                 $this->max_packet = $value;
             }
             $this->max_packet -= 2000;
         } else {
             if ($this->type == 'memcache') {
                 $stats = $this->db->getStats();
                 $remaining = $stats['limit_maxbytes'] - $stats['bytes'];
                 $this->max_packet = min($remaining / 5, $this->max_packet);
             } else {
                 if ($this->type == 'apc' && function_exists('apc_sma_info')) {
                     $stats = apc_sma_info();
                     $this->max_packet = min($stats['avail_mem'] / 5, $this->max_packet);
                 }
             }
         }
     }
     return $this->max_packet;
 }
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:28,代码来源:rcube_cache_shared.php

示例5: connect

 /**
  * @throws \envtesting\Error
  */
 public function connect()
 {
     if (!extension_loaded('memcache')) {
         throw new \envtesting\Error('PHP extension \'memcache\' is not loaded');
     }
     if (!class_exists('Memcache')) {
         throw new \envtesting\Error('Memcache classs is missing.');
     }
     try {
         $this->memcache = new \Memcache();
         $this->memcache->connect($this->host, $this->port, true);
         if ($this->memcache->getStats() == false) {
             throw new \Exception('Memcache status return false.');
         }
     } catch (\Exception $e) {
         throw new \envtesting\Error('Memcached connection faild: ' . $this->host . ':' . $this->port . ' : ' . $e->getMessage());
     }
 }
开发者ID:wikidi,项目名称:envtesting,代码行数:21,代码来源:Connection.php

示例6: get_statistics

 public function get_statistics()
 {
     $a = $this->_memcache->getStats();
     if (count($a) > 0) {
         $keys = array_keys($a);
         $key = $keys[0];
         return $a[$key];
     }
     return $a;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:10,代码来源:Cache_Memcached.php

示例7: stats

 /**
  * Get stats about cluster
  *
  * @param bool $extended detailed stats?
  * @return mixed - array on success; false on failure
  **/
 public function stats($extended = true)
 {
     if ($this->open()) {
         if ($extended) {
             return $this->memcache->getExtendedStats();
         } else {
             return $this->memcache->getStats();
         }
     }
     return false;
 }
开发者ID:nesbert,项目名称:nobjects,代码行数:17,代码来源:Data.php

示例8: checkDriver

 /**
  * 检查连接状态
  * @return boolean
  */
 public function checkDriver()
 {
     if (!$this->isConnected && $this->reConnected < $this->maxReConnected) {
         if ($this->handler->getStats() !== false) {
             $this->isConnected = true;
         } else {
             $this->initServers();
         }
         if (!$this->isConnected) {
             $this->reConnected++;
         } else {
             $this->reConnected = 0;
         }
     }
     return $this->isConnected;
 }
开发者ID:dongnan,项目名称:linkcache,代码行数:20,代码来源:Memcache.php

示例9: get_online_objects

function get_online_objects()
{
    $device_browser_list = mmc_array_values(NS_DEVICE_LIST);
    time_print('性能分析:取列表:');
    if (isset($_GET['debug'])) {
        $device_count = mmc_array_length(NS_DEVICE_LIST);
        $memcache_obj = new Memcache();
        $memcache_obj->connect(MEMC_HOST, MEMC_PORT);
        $stats = $memcache_obj->getStats();
        $memcache_obj->close();
        $dbg_print = '开始时间:' . getDateStyle($stats['time'] - $stats['uptime']);
        $dbg_print .= ' 使用内存: ' . bytesToSize($stats['bytes']) . '/' . bytesToSize($stats['limit_maxbytes']);
        $dbg_print .= '<br>清理时间:' . getDateStyle(async_timer('/on_timer_online_list.php'));
        $dbg_print .= ' 维护设备数: ' . $device_count . '  活跃设备数: ' . count($device_browser_list);
        $xmlStr = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/channels-stats');
        $channels = json_decode($xmlStr);
        $dbg_print .= '<br>推送开始:' . getDateStyle(time() - $channels->uptime) . ' 频道数: ' . $channels->channels;
        $dbg_print .= ' 订阅数: ' . $channels->subscribers . ' 消息数: ' . $channels->published_messages;
        $dbg_print .= '<br>流程计数: ' . counter() . '<br>';
        echo $dbg_print;
    }
    /******************************************************
    	预处理:账户绑定列表
    	******************************************************/
    $aDataSet = [];
    foreach ($device_browser_list as $browser) {
        if (empty($browser)) {
            continue;
        }
        $account = @$browser['bind_account'];
        $device = $browser['device'];
        $useragent = $browser['UserAgent'];
        $ref_obj = $browser['Visiting'] ? parse_url($browser['Visiting']) : null;
        $visiting = @$ref_obj['host'];
        $is_mobile = $browser['ismobiledevice'] ? 'mobi' : 'desk';
        $aDataSet[] = [$account, $browser['region'], $visiting, $browser['browser'], $browser['platform'], $is_mobile, $browser['device_name'], $browser['device']];
    }
    time_print('整合:');
    if (isset($_GET['debug'])) {
        echo time_print();
    }
    return $aDataSet;
}
开发者ID:sdgdsffdsfff,项目名称:html-sensor,代码行数:43,代码来源:index.php

示例10: delete

 /**
  * Delete one or several data from cache (* joker can be used, but avoid it !)
  * 	E.g.: delete('*'); delete('my_prefix_*'); delete('my_key_name');
  *
  * @param string $key
  * @return bool
  */
 public function delete($key)
 {
     if ($key == '*') {
         $this->flush();
     } elseif (strpos($key, '*') === false) {
         $this->_delete($key);
     } else {
         // Get keys (this code comes from Doctrine 2 project)
         $pattern = str_replace('\\*', '.*', preg_quote($key));
         $servers = $this->getMemcachedServers();
         if (is_array($servers) && count($servers) > 0 && method_exists('Memcache', 'getStats')) {
             $all_slabs = $this->memcache->getStats('slabs');
         }
         if (isset($all_slabs) && is_array($all_slabs)) {
             foreach ($all_slabs as $server => $slabs) {
                 if (is_array($slabs)) {
                     foreach (array_keys($slabs) as $i => $slab_id) {
                         // $slab_id is not an int but a string, using the key instead ?
                         if (is_int($i)) {
                             $dump = $this->memcache->getStats('cachedump', (int) $i);
                             if ($dump) {
                                 foreach ($dump as $entries) {
                                     if ($entries) {
                                         foreach ($entries as $key => $data) {
                                             if (preg_match('#^' . $pattern . '$#', $key)) {
                                                 $this->_delete($key);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:46,代码来源:CacheMemcache.php

示例11: GetStatus

 function GetStatus($id)
 {
     $arStats = array();
     $arServer = CClusterMemcache::GetByID($id);
     if (is_array($arServer)) {
         $ob = new Memcache();
         if (@$ob->connect($arServer["HOST"], $arServer["PORT"])) {
             $arStats = array('uptime' => null, 'version' => null, 'cmd_get' => null, 'cmd_set' => null, 'get_misses' => null, 'get_hits' => null, 'limit_maxbytes' => null, 'bytes' => null, 'curr_items' => null, 'listen_disabled_num' => null);
             $ar = $ob->getStats();
             foreach ($arStats as $key => $value) {
                 $arStats[$key] = $ar[$key];
             }
         }
     }
     return $arStats;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:memcache.php

示例12: explode

	}

	if ($mesg)
		print '<br>' . $mesg;

	if (!empty($conf->memcached->host)) {
		$tmparray = explode(':', $conf->memcached->host);
		$server = $tmparray[0];
		$port = $tmparray[1] ? $tmparray[1] : 11211;

		//dol_syslog("Try to connect to server " . $server . " port " . $port . " with class " . get_class($m));
		$result = $m->addServer($server, $port);
		//$m->setOption(Memcached::OPT_COMPRESSION, false);
		//print "xxx".$result;
		// Read cache
		$arraycache = $m->getStats();
		//var_dump($arraycache);
	}

	// Action
	print '<div class="tabsAction">';
	print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=clear">' . $langs->trans("FlushCache") . '</a>';
	print '</div>';
	print '<br>';


	// Statistics of cache server
	print '<table class="noborder" width="60%">';
	print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("Status") . '</td></tr>';

	if (empty($conf->memcached->host)) {
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:memcached.php

示例13: Memcache

<?php

//
// apt-get install php5-memcache
//
$memcache_enabled = extension_loaded("memcache");
if ($memcache_enabled) {
    echo "extension loaded";
} else {
    echo "extension not loaded";
}
$mc = new Memcache();
$mc->connect("localhost", 11211);
print_r($mc->getStats());
开发者ID:scriptzteam,项目名称:newzNZB-premium-indexer,代码行数:14,代码来源:memcache.php

示例14: Memcache

    function memCache2html()
    {
        $html = '';
        if (!class_exists('Memcache')) {
            return '';
        }
        $cache = new Memcache();
        $cache->connect('127.0.0.1', 11211);
        if ($res = $cache->getstats('items') and !empty($res['items'])) {
            if (MEMCACHE_CRYPT) {
                return '<b>Memcache</b>: Для отображения таблицы, отключите шифрование кэша в sys/config.php <b>MEMCACHE_CRYPT</b>';
            }
            $html .= '<b>Memcache</b>. В целях безопасности включите шифрование кэша в sys/config.php <b>MEMCACHE_CRYPT</b>.
                    <style type="text/css">
table.sys th{background-color: #9999ff; padding:7px; text-align: center;}
table.sys td{background-color: #ccccff; padding:7px; text-align: center;white-space:pre}
table.sys td.left{text-align: left;}
.red{color:red;}
</style><table class="sys" style="width:100%;">
                    <tr><th style="width:50px;">№</th><th>Ключ</th><th>Значение</th><th>Время жизни</th><th><a href="' . H . '/panel/settings/memcache_table_off" title="Закрыть таблицу" class="red">[X]</a></th></tr>';
            $i = 0;
            foreach ($res['items'] as $key => $val) {
                $items = $cache->getStats('cachedump', $key);
                foreach ($items as $key => $val) {
                    $i++;
                    $live_time = $val[1] - TIME;
                    if ($live_time < 0) {
                        $live_time = 'Вечная';
                    } else {
                        $live_time .= ' сек.';
                    }
                    $html .= '<tr><td>' . $i . '</td><td>' . $key . '</td>
                        <td class="left">' . htmlspecialchars(print_r($cache->get($key), true)) . '</td>
                        <td>' . $live_time . '</td><td><a class="red" title="Удалить" href="' . H . '/panel/settings/del_memcached/' . $key . '">[X]</a></td></tr>';
                }
            }
            $html .= '</table>';
        }
        return $html;
    }
开发者ID:kostarev,项目名称:test,代码行数:40,代码来源:SiteRead.php

示例15: Memcache

<?php

$server_ip = 'localhost';
$server_port = '11211';
$load = extension_loaded('memcache');
if (!$load) {
    echo "The Memcache isn't loaded.";
} else {
    $mem = new Memcache();
    $mem->addServer($server_ip, $server_port);
    $status = $mem->getStats();
    $foundCache = (double) $status["get_hits"] / (double) $status["cmd_get"] * 100;
    $foundCache = round($foundCache, 3);
    $cacheMiss = 100 - $foundCache;
    $read = (double) $status["bytes_read"] / (1024 * 1024);
    $write = (double) $status["bytes_written"] / (1024 * 1024);
    $totalSize = (double) $status["limit_maxbytes"] / (1024 * 1024);
    echo "<table border='1'>";
    echo "<tr><td>Memcache version:</td><td> " . $status["version"] . "</td></tr>";
    echo "<tr><td>Host: </td><td> " . $_SERVER["HTTP_HOST"] . "</td></tr>";
    echo "<tr><td>Port: </td><td> " . $server_port . "</td></tr>";
    echo "<tr><td>Process id </td><td>" . $status["pid"] . "</td></tr>";
    echo "<tr><td>Running time </td><td>" . floor($status["uptime"] / 60) . " min</td></tr>";
    echo "<tr><td>Accumulated user time by process </td><td>" . $status["rusage_user"] . " seconds</td></tr>";
    echo "<tr><td>Accumulated system time for this process </td><td>" . $status["rusage_system"] . " seconds</td></tr>";
    echo "<tr><td>Items stored by this server ever since it started </td><td>" . $status["total_items"] . "</td></tr>";
    echo "<tr><td>Open connections </td><td>" . $status["curr_connections"] . "</td></tr>";
    echo "<tr><td>All connections opened since the server started </td><td>" . $status["total_connections"] . "</td></tr>";
    echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status["connection_structures"] . "</td></tr>";
    echo "<tr><td>Cumulative number for get requests </td><td>" . $status["cmd_get"] . "</td></tr>";
    echo "<tr><td> Cumulative number for storage requests </td><td>" . $status["cmd_set"] . "</td></tr>";
开发者ID:didijudo,项目名称:observer,代码行数:31,代码来源:index.php


注:本文中的Memcache::getStats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。