ServerInfoV26x.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Commands;
  11. class ServerInfoV26x extends ServerInfo
  12. {
  13. public function parseResponse($data)
  14. {
  15. $info = array();
  16. $current = null;
  17. $infoLines = explode("\r\n", $data, -1);
  18. foreach ($infoLines as $row) {
  19. if ($row === '') {
  20. continue;
  21. }
  22. if (preg_match('/^# (\w+)$/', $row, $matches)) {
  23. $info[$matches[1]] = array();
  24. $current = &$info[$matches[1]];
  25. continue;
  26. }
  27. list($k, $v) = explode(':', $row);
  28. if (!preg_match('/^db\d+$/', $k)) {
  29. if ($k === 'allocation_stats') {
  30. $current[$k] = $this->parseAllocationStats($v);
  31. continue;
  32. }
  33. $current[$k] = $v;
  34. }
  35. else {
  36. $current[$k] = $this->parseDatabaseStats($v);
  37. }
  38. }
  39. return $info;
  40. }
  41. }