NullLockBackend.php 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Drupal\Core\Lock;
  3. /**
  4. * Defines a Null lock backend.
  5. *
  6. * This implementation won't actually lock anything and will always succeed on
  7. * lock attempts.
  8. *
  9. * @ingroup lock
  10. */
  11. class NullLockBackend implements LockBackendInterface {
  12. /**
  13. * Current page lock token identifier.
  14. *
  15. * @var string
  16. */
  17. protected $lockId;
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function acquire($name, $timeout = 30.0) {
  22. return TRUE;
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function lockMayBeAvailable($name) {
  28. return TRUE;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function wait($name, $delay = 30) {}
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function release($name) {}
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function releaseAll($lock_id = NULL) {}
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function getLockId() {
  46. if (!isset($this->lockId)) {
  47. $this->lockId = uniqid(mt_rand(), TRUE);
  48. }
  49. return $this->lockId;
  50. }
  51. }