LockHandlerInterface.php 696 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace Michel\Lock;
  3. interface LockHandlerInterface
  4. {
  5. /**
  6. * Attempts to acquire an exclusive lock for the given key.
  7. *
  8. * @param string $key The unique identifier for the lock.
  9. * @param bool $wait Whether to wait (blocking mode) until the lock becomes
  10. * available or return false immediately.
  11. * * @return bool True if the lock was successfully acquired, false otherwise.
  12. */
  13. public function lock(string $key, bool $wait = false): bool;
  14. /**
  15. * Releases the lock associated with the given key.
  16. *
  17. * @param string $key The unique identifier for the lock to be released.
  18. */
  19. public function unlock(string $key): void;
  20. }