diff --git a/libraries/Redis.php b/libraries/Redis.php index 546fda6..487454a 100644 --- a/libraries/Redis.php +++ b/libraries/Redis.php @@ -323,6 +323,29 @@ private function _encode_request($request, $data = NULL) } return $request; } + + /** + * Info + * + * Overrides the default Redis response, + * so we return a nice array instead of a nasty string. + * @return array + */ + public function info() + { + $response = $this->command('INFO'); + $data = array(); + $pieces = explode("\r\n", $response); + + // Extract the key and value + foreach ($pieces as $piece) + { + $parts = explode(':', $piece); + $data[$parts[0]] = $parts[1]; + } + + return $data; + } /** * Debug diff --git a/tests/Redis_test.php b/tests/Redis_test.php index ff430ad..b386fe0 100644 --- a/tests/Redis_test.php +++ b/tests/Redis_test.php @@ -99,4 +99,14 @@ public function test_overloading() } + /** + * Test info + */ + public function test_info() + { + $info = $this->redis->info(); + $this->assertTrue(isset($info['redis_version'])); + $this->assertTrue(isset($info['process_id'])); + } + } \ No newline at end of file