-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmemcached.php
89 lines (76 loc) · 2.58 KB
/
memcached.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
$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://cachedcommons.org/cache/jquery/1.4.2/javascripts/jquery.js"></script>
<script type="text/javascript" src="http://cachedcommons.org/cache/jquery-table-sorter/2.0.3/javascripts/jquery-table-sorter-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="#" onclick="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>