LockManagerInterface.php 957 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Framework\Lock;
  8. /**
  9. * Interface of a lock manager
  10. *
  11. * @api
  12. * @since 101.0.5
  13. */
  14. interface LockManagerInterface
  15. {
  16. /**
  17. * Sets a lock
  18. *
  19. * @param string $name lock name
  20. * @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
  21. * @return bool
  22. * @api
  23. * @since 101.0.5
  24. */
  25. public function lock(string $name, int $timeout = -1): bool;
  26. /**
  27. * Releases a lock
  28. *
  29. * @param string $name lock name
  30. * @return bool
  31. * @api
  32. * @since 101.0.5
  33. */
  34. public function unlock(string $name): bool;
  35. /**
  36. * Tests if lock is set
  37. *
  38. * @param string $name lock name
  39. * @return bool
  40. * @api
  41. * @since 101.0.5
  42. */
  43. public function isLocked(string $name): bool;
  44. }