InfoV24x.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Predis\Commands;
  3. class InfoV24x extends Info {
  4. public function canBeHashed() { return false; }
  5. public function getId() { return 'INFO'; }
  6. public function parseResponse($data) {
  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. }