ServerInfoV26x.php 977 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Predis\Commands;
  3. class ServerInfoV26x extends ServerInfo
  4. {
  5. public function parseResponse($data)
  6. {
  7. $info = array();
  8. $current = null;
  9. $infoLines = explode("\r\n", $data, -1);
  10. foreach ($infoLines as $row) {
  11. if ($row === '') {
  12. continue;
  13. }
  14. if (preg_match('/^# (\w+)$/', $row, $matches)) {
  15. $info[$matches[1]] = array();
  16. $current = &$info[$matches[1]];
  17. continue;
  18. }
  19. list($k, $v) = explode(':', $row);
  20. if (!preg_match('/^db\d+$/', $k)) {
  21. if ($k === 'allocation_stats') {
  22. $current[$k] = $this->parseAllocationStats($v);
  23. continue;
  24. }
  25. $current[$k] = $v;
  26. }
  27. else {
  28. $current[$k] = $this->parseDatabaseStats($v);
  29. }
  30. }
  31. return $info;
  32. }
  33. }