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


PHP Memcache::getstats方法代码示例

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


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

示例1: __construct

 /**
  * 初始化缓存配置信息
  * @param array $configs 缓存配置信息
  */
 public function __construct($configs)
 {
     if (!$configs) {
         if (APP_DEBUG) {
             E("必须传入缓存配置信息!");
         }
     }
     $this->configs = $configs;
     $Mem = new \Memcache();
     foreach ($this->configs['server'] as $value) {
         call_user_func_array(array($Mem, 'addServer'), $value);
     }
     if (!$Mem->getstats()) {
         if (APP_DEBUG) {
             E("Unable to connect the Memcache server!");
         }
     }
     self::$Mem = $Mem;
 }
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:23,代码来源:MemoCache.class.php

示例2: mem_status

function mem_status()
{
    global $config;
    $config = object_to_array($config);
    $mem = new Memcache();
    $host = "127.0.0.1";
    $port = isset($config['module']['memcached1.2.6']['port']) ? $config['module']['memcached1.2.6']['port'] : 11211;
    $mem->connect($host, $port);
    print "<table style='border: 1px solid #D9D9D9;'>";
    print "<thead><th>Memcache Status</th></thead>";
    foreach ($mem->getstats() as $key => $value) {
        print "<tr><td style='background: #E3E3F1;'>{$key}</td> <td>{$value}</td></tr>\n";
    }
    print "</table>";
    print "<p>";
    $mem->set('test', 'This is a test value', 0, 60);
    print $mem->get('test');
    print "</p>";
    $mem->flush();
}
开发者ID:hhd85,项目名称:PPServ,代码行数:20,代码来源:index.php

示例3: __construct

 /**
  * 初始化缓存配置信息
  * @param array $configs 缓存配置信息
  */
 public function __construct($configs)
 {
     if (!$configs) {
         if (APP_DEBUG) {
             E("cache configure args is needed!");
         }
     }
     if (!extension_loaded("memcache")) {
         E("please install memcache extension.");
     }
     $this->configs = $configs;
     $Mem = new \Memcache();
     foreach ($this->configs['server'] as $value) {
         call_user_func_array(array($Mem, 'addServer'), $value);
     }
     if (!$Mem->getstats()) {
         if (APP_DEBUG) {
             E("Unable to connect the Memcache server!");
         }
     }
     self::$Mem = $Mem;
 }
开发者ID:yangjian102621,项目名称:herosphp,代码行数:26,代码来源:MemoCache.class.php

示例4: Memcache

<?php

/**
 * Created by PhpStorm.
 * User: PSV
 * Date: 29.09.15
 * Time: 19:29
 */
$cache = new Memcache();
$cache->connect("localhost", 11211, 1);
$cache->set("putin", "hamlo");
echo $cache->get("putin") . "<br>";
$cache->set("putin1", "durak");
echo "putin1" . $cache->get("putin1") . "<br>";
$a = 2;
$a = $a++ + ++$a - $a--;
echo $a;
$cache->delete("putin1");
//file_get_contents()
$res = $cache->get("putin1");
echo "putin1" . $res . "<br>";
//$cache->add("putin2","hamlokhflsdfsds", MEMCACHE_COMPRESSED, 10);
echo $cache->get("putin2");
$cache->add("views", 1);
$cache->increment("views");
echo $cache->get("views");
//$cache->delete("views");
echo "<pre>";
//$cache->flush();
var_dump($cache->getstats());
$cache->close();
开发者ID:sepaev,项目名称:domains,代码行数:31,代码来源:cache.php

示例5: 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

示例6: get_info

 /**
  * @see Temporary_cache_driver::get_info()
  */
 public function get_info()
 {
     $info = $this->memcache->getstats();
     return array('available' => $info['limit_maxbytes'] - $info['bytes'], 'max' => $info['limit_maxbytes'], 'occupied' => $info['bytes']);
 }
开发者ID:Cotonti,项目名称:valencia,代码行数:8,代码来源:cache.php

示例7: Memcache

<?php

/*
 * 统计各节点的平均命中率
 */
require './13-01-config.php';
$mem = new Memcache();
$gets = 0;
$hits = 0;
foreach ($_memserv as $k => $v) {
    $mem->connect($v['host'], $v['port'], 2);
    $res = $mem->getstats();
    $gets += $res['cmd_get'];
    $hits += $res['get_hits'];
}
$rate = 1;
if ($gets > 0) {
    $rate = $hits / $gets;
}
echo $rate * 100, '%';
开发者ID:cgirl,项目名称:memcache,代码行数:20,代码来源:13-04-load.php


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