RedisTransaction.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tioncico
  5. * Date: 19-10-4
  6. * Time: 下午3:37
  7. */
  8. namespace EasySwoole\Redis;
  9. class RedisTransaction
  10. {
  11. protected $commandLog = [];
  12. protected $isTransaction = false;
  13. const IGNORE_COMMAND = [
  14. 'discard',
  15. 'exec',
  16. 'multi',
  17. // 'unWatch',
  18. // 'watch',
  19. ];
  20. /**
  21. * @return array
  22. */
  23. public function getCommandLog(): array
  24. {
  25. return $this->commandLog;
  26. }
  27. /**
  28. * @param array $commandLog
  29. */
  30. public function setCommandLog(array $commandLog): void
  31. {
  32. $this->commandLog = $commandLog;
  33. }
  34. function addCommand($command)
  35. {
  36. $this->commandLog[] = $command;
  37. }
  38. /**
  39. * @return bool
  40. */
  41. public function isTransaction(): bool
  42. {
  43. return $this->isTransaction;
  44. }
  45. /**
  46. * @param bool $isTransaction
  47. */
  48. public function setIsTransaction(bool $isTransaction): void
  49. {
  50. $this->isTransaction = $isTransaction;
  51. }
  52. }