diff --git a/README.md b/README.md index d2b24c8..1a263d9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # redis2table -Simple table based viewer of Redis. You can monitor every redis keys like Key, List, Set, Sorted Set, Hash. +Simple table based viewer of Redis. You can monitor every redis keys like Key, List, Set, Sorted Set, Hash and Redis info. ## Demo site @@ -24,47 +24,15 @@ $ cd redis2table $ php54 -S localhost:8080 ``` -After that, visit [http://localhost:8080/redis2table](http://localhost:80/redis2table) (by Apache et al.) or [http://localhost:8080/](http://localhost:8080/) (by built-in webserver) +After that, visit [http://localhost:8080/index.php?host=localhost&port=6379](http://localhost:8080/index.php?host=localhost&port=6379) (by Apache et al.). ### CentOS similar to Ubuntu / Debian. -## Edit - -First, go to index.php… - -``` -$ cd redis2table -$ vi index.php -``` - -Next, edit index.php line #5 on your Redis env. - -``` -$redis->connect("localhost", 6379, 2.5); -// "2.5" means timeout. So let it be. -``` - -If you redis data is empty, please uncomment "Testing data". - -``` -/* Testing data -$redis->flushAll(); - -$redis->set(uniqid("key_"), uniqid("key_value_1_")); - -// ~ omitted ~ // - -$redis->zAdd($key_zset_03, time(), uniqid("zset_value_22_")); -$redis->zAdd($key_zset_03, time(),uniqid("zset_value_23_")); -*/ -``` - - ## ToDo -- auto reload +- auto reload by ajax - more document - +- cool design diff --git a/index.php b/index.php index 9bf432a..b9f3103 100644 --- a/index.php +++ b/index.php @@ -2,40 +2,52 @@ $title = "redis2table"; $redis = new Redis(); -$redis->connect("localhost", 6379, 2.5); // Please edit here on your env. 2.5 sec timeout. - -/* Testing data - $redis->flushAll(); - - $redis->set(uniqid("key_"), uniqid("key_value_1_")); - $redis->set(uniqid("key_"), uniqid("key_value_2_")); - $redis->set(uniqid("key_"), uniqid("key_value_3_")); - - $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_1', 'salary' => 1000)); - $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_2', 'salary' => 2000)); - $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_3', 'salary' => 3000)); - - $redis->rPush(uniqid("list_"), uniqid("list_value_01_"), uniqid("list_value_02_"), uniqid("list_value_03_")); - $redis->rPush(uniqid("list_"), uniqid("list_value_11_"), uniqid("list_value_12_"), uniqid("list_value_13_")); - $redis->rPush(uniqid("list_"), uniqid("list_value_21_"), uniqid("list_value_22_"), uniqid("list_value_23_")); - - $redis->sAdd(uniqid("set_"), uniqid("set_value_01_"), uniqid("set_value_02_")); - $redis->sAdd(uniqid("set_"), uniqid("set_value_11_"), uniqid("set_value_12_")); - $redis->sAdd(uniqid("set_"), uniqid("set_value_21_"), uniqid("set_value_22_")); - - $key_zset_01 = uniqid("zset_"); - $redis->zAdd($key_zset_01, time(), uniqid("zset_value_01_")); - $redis->zAdd($key_zset_01, time(), uniqid("zset_value_02_")); - $redis->zAdd($key_zset_01, time(), uniqid("zset_value_03_")); - $key_zset_02 = uniqid("zset_"); - $redis->zAdd($key_zset_02, time(), uniqid("zset_value_11_")); - $redis->zAdd($key_zset_02, time(), uniqid("zset_value_12_")); - $redis->zAdd($key_zset_02, time(), uniqid("zset_value_13_")); - $key_zset_03 = uniqid("zset_"); - $redis->zAdd($key_zset_03, time(), uniqid("zset_value_21_")); - $redis->zAdd($key_zset_03, time(), uniqid("zset_value_22_")); - $redis->zAdd($key_zset_03, time(), uniqid("zset_value_23_")); - */ + +if (!isset($_GET["host"]) or !isset($_GET["port"])) { + die('
Error. Wrong host or port. Access like this -> http://localhost:8080/index.php?host=localhost&port=6379
Or if you want erase and set random data of redis, please like this -> http://localhost:8080/index.php?host=localhost&port=6379&init=true
'); +} + +$host = htmlspecialchars($_GET["host"]); +$port = htmlspecialchars($_GET["port"]); +$timeout = 2.5; + +if (!$redis->connect($host, $port, $timeout)) { + die("Error. Could not access to local redis server. Please check whether redis is running or not.
"); +} + +// Testing data (Please use it if you have empty redis data) +if (isset($_GET["init"]) and $_GET["init"] === "true") { + $redis->flushAll(); + + $redis->set(uniqid("key_"), uniqid("key_value_1_")); + $redis->set(uniqid("key_"), uniqid("key_value_2_")); + $redis->set(uniqid("key_"), uniqid("key_value_3_")); + + $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_1', 'salary' => 1000)); + $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_2', 'salary' => 2000)); + $redis->hMset(uniqid("hash_"), array('name' => 'yukkuri_3', 'salary' => 3000)); + + $redis->rPush(uniqid("list_"), uniqid("list_value_01_"), uniqid("list_value_02_"), uniqid("list_value_03_")); + $redis->rPush(uniqid("list_"), uniqid("list_value_11_"), uniqid("list_value_12_"), uniqid("list_value_13_")); + $redis->rPush(uniqid("list_"), uniqid("list_value_21_"), uniqid("list_value_22_"), uniqid("list_value_23_")); + + $redis->sAdd(uniqid("set_"), uniqid("set_value_01_"), uniqid("set_value_02_")); + $redis->sAdd(uniqid("set_"), uniqid("set_value_11_"), uniqid("set_value_12_")); + $redis->sAdd(uniqid("set_"), uniqid("set_value_21_"), uniqid("set_value_22_")); + + $key_zset_01 = uniqid("zset_"); + $redis->zAdd($key_zset_01, time(), uniqid("zset_value_01_")); + $redis->zAdd($key_zset_01, time(), uniqid("zset_value_02_")); + $redis->zAdd($key_zset_01, time(), uniqid("zset_value_03_")); + $key_zset_02 = uniqid("zset_"); + $redis->zAdd($key_zset_02, time(), uniqid("zset_value_11_")); + $redis->zAdd($key_zset_02, time(), uniqid("zset_value_12_")); + $redis->zAdd($key_zset_02, time(), uniqid("zset_value_13_")); + $key_zset_03 = uniqid("zset_"); + $redis->zAdd($key_zset_03, time(), uniqid("zset_value_21_")); + $redis->zAdd($key_zset_03, time(), uniqid("zset_value_22_")); + $redis->zAdd($key_zset_03, time(), uniqid("zset_value_23_")); +} // prepare arrays for each types $key_arr = array(); @@ -76,24 +88,6 @@ } } -$list_table = array(); -if (count($list_arr) !== 0) { - foreach ($list_arr as $key) { - $rowspan = $redis->lSize($key); - $counter = $rowspan; - $rep = '"; + $res .= $value; + $res .= " | "; + } + $res .= "
Show all the Redis keys and values.
+Redis monitoring tool. Available Key, List, Set, Sorted Set, Hash and Redis Info.
+Access like this -> http://localhost:8080/index.php?host=localhost&port=6379
key | -value | -ttl | -
key | -value | -
key | -value | -
key | -value | -score | -
key | -field | -value | -