You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Redis
  7. * @since 2011-07-29
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class RedisDebug
  12. {
  13. private $redis;
  14. public function __construct($redis)
  15. {
  16. if (!is_a($redis, 'Redis')) {
  17. throw new GeneralException();
  18. }
  19. $this->redis = $redis;
  20. }
  21. public function __call($name, $arguments)
  22. {
  23. $command = $this->r_implode(', ', $arguments);
  24. $profiler = Profiler::getInstance()->profilerCommand('Redis->' . $name, $command);
  25. $data = call_user_func_array(array($this->redis, $name), $arguments);
  26. $profiler->end();
  27. return $data;
  28. }
  29. protected function r_implode($glue, $pieces)
  30. {
  31. $retVal = array();
  32. foreach ($pieces as $r_pieces) {
  33. if (is_array($r_pieces)) {
  34. $retVal[] = '(' . $this->r_implode($glue, $r_pieces) . ')';
  35. } else {
  36. $retVal[] = $r_pieces;
  37. }
  38. }
  39. return implode($glue, $retVal);
  40. }
  41. }