php memcached-gui工具

转载: https://github.com/mailopl/memcached-gui/blob/master/memcached.php

 

适用于在服务端查看memcache内存数据

 

php代码:

<?php
error_reporting(0);
$memcache = new Memcache();
$memcache->addServer('127.0.0.1'); // edit here if your memcached server differs from localhost
$list = array();
$allSlabs = $memcache->getExtendedStats('slabs');
$items = $memcache->getExtendedStats('items');
foreach($allSlabs as $server => $slabs) {
    foreach($slabs AS $slabId => $slabMeta) {
        $cdump = $memcache->getExtendedStats('cachedump',(int)$slabId);
        foreach($cdump AS $server => $entries) {
            if($entries) {
                foreach($entries AS $eName => $eData) {
                    $list[$eName] = array(
                        'key' => $eName,
                        'value' => $memcache->get($eName)
                    );
                }
            }
        }
    }
}
ksort($list);
if (isset($_GET['del'])) {
    $memcache->delete($_GET['del']);
    header("Location: " . $_SERVER['PHP_SELF']);
}
if (isset($_GET['flush'])) {
    $memcache->flush();
    header("Location: " . $_SERVER['PHP_SELF']);
}
if (isset($_GET['set'])) {
    $memcache->set($_GET['set'], $_GET['value']);
    header("Location: " . $_SERVER['PHP_SELF']);
}
?>
<head>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
    <script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.12.3/jquery.js"></script>
    <script type="text/javascript" src="http://cdn.bootcss.com/jquery.tablesorter/2.28.5/js/jquery.tablesorter.min.js"></script>

</head>
<body>

<div class="container" style="width: 940px;">
    <h3>memcached</h3>
    <table cellpadding="0" cellspacing="0" class="tablesorter table table-bordered table-hover table-striped">
        <thead>
        <tr>
            <th>key</th>
            <th>value</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($list as $i): ?>
            <tr>
                <td><?php echo $i['key'] ?></td>
                <td><?php echo $i['value'] ?></td>
                <td><a href="memcached.php?del=<?php echo $i['key'] ?>">X</a>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <center>
        <a href="memcached.php?flush=1">FLUSH</a> <br />
        <br />
        <a href="#" οnclick="memcachedSet()">SET</a>
    </center>

    <script type="text/javascript">
        $(document).ready(function(){
            $("table").tablesorter();
        });
        function memcachedSet() {
            key = prompt("Key: ");
            value = prompt("Value: ");
            window.location.href = "memcached.php?set="+ key +"&value=" + value;
        }
    </script>
</body>

 

效果:

 

 

之前也用过fastonosql 非常好用,但可惜开始收费了。

还有一个web管理软件:TreeSoft数据库管理系统

http://www.treesoft.cn/dms.html

 

转载于:https://www.cnblogs.com/dcb3688/p/4608029.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值