InfoV24x.php 1016 B

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