mirror of
https://github.com/cytopia/devilbox.git
synced 2025-04-08 03:24:15 +00:00
Show Redis keys grouped by DB
This commit is contained in:
parent
ed52e7e3d8
commit
8e14009d3d
@ -24,16 +24,26 @@
|
||||
<table class="table table-striped ">
|
||||
<thead class="thead-inverse ">
|
||||
<tr>
|
||||
<th>DB</th>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach (loadClass('Redis')->getKeys() as $key => $value): ?>
|
||||
<tr>
|
||||
<td><?php echo $key;?></td>
|
||||
<td><?php print_r($value);?></td>
|
||||
<?php foreach (loadClass('Redis')->getKeys() as $db_name => $keys): ?>
|
||||
<tr class="table-info">
|
||||
<th colspan="3">
|
||||
<?php echo $db_name;?>
|
||||
</th>
|
||||
</tr>
|
||||
<?php foreach ($keys as $key=> $val): ?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><?php echo $key;?></td>
|
||||
<td><code><?php print_r($val);?></code></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -80,13 +80,29 @@ class Redis extends BaseClass implements BaseInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function getDatabases()
|
||||
{
|
||||
$databases = array();
|
||||
|
||||
foreach ($this->getInfo() as $key => $val) {
|
||||
if (preg_match('/db[0-9]+/', $key)) {
|
||||
$databases[] = str_replace('db', '', $key);
|
||||
}
|
||||
}
|
||||
return ($databases);
|
||||
}
|
||||
|
||||
public function getKeys()
|
||||
{
|
||||
$store = array();
|
||||
if ($this->_redis) {
|
||||
$keys = $this->_redis->keys('*');
|
||||
foreach ($keys as $key) {
|
||||
$store[$key] = $this->_redis->get($key);
|
||||
$databases = $this->getDatabases();
|
||||
foreach ($databases as $db) {
|
||||
$this->_redis->select($db);
|
||||
$keys = $this->_redis->keys('*');
|
||||
foreach ($keys as $key) {
|
||||
$store[$db][$key] = $this->_redis->get($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $store;
|
||||
|
Loading…
x
Reference in New Issue
Block a user