ILockingStorage.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Files\Storage;
  8. use OCP\Lock\ILockingProvider;
  9. /**
  10. * Storage backends that require explicit locking
  11. *
  12. * Storage backends implementing this interface do not need to implement their own locking implementation but should use the provided lockingprovider instead
  13. * The implementation of the locking methods only need to map internal storage paths to "lock keys"
  14. *
  15. * @since 9.0.0
  16. */
  17. interface ILockingStorage {
  18. /**
  19. * @param string $path The path of the file to acquire the lock for
  20. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  21. * @param \OCP\Lock\ILockingProvider $provider
  22. * @throws \OCP\Lock\LockedException
  23. * @since 9.0.0
  24. */
  25. public function acquireLock($path, $type, ILockingProvider $provider);
  26. /**
  27. * @param string $path The path of the file to acquire the lock for
  28. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  29. * @param \OCP\Lock\ILockingProvider $provider
  30. * @throws \OCP\Lock\LockedException
  31. * @since 9.0.0
  32. */
  33. public function releaseLock($path, $type, ILockingProvider $provider);
  34. /**
  35. * @param string $path The path of the file to change the lock for
  36. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  37. * @param \OCP\Lock\ILockingProvider $provider
  38. * @throws \OCP\Lock\LockedException
  39. * @since 9.0.0
  40. */
  41. public function changeLock($path, $type, ILockingProvider $provider);
  42. }