LockHandler
class LockHandler
LockHandler class provides a simple abstraction to lock anything by means of a file lock.
A locked file is created based on the lock name when calling lock(). Other lock handlers will not be able to lock the same name until it is released (explicitly by calling release() or implicitly when the instance holding the lock is destroyed).
Methods
| __construct(string $name, string|null $lockPath = null) | ||
| bool | lock(bool $blocking = false) Lock the resource. | |
| release() Release the resource. |
Details
__construct(string $name, string|null $lockPath = null)
Parameters
| string | $name | The lock name |
| string|null | $lockPath | The directory to store the lock. Default values will use temporary directory |
Exceptions
| IOException | If the lock directory could not be created or is not writable |
bool lock(bool $blocking = false)
Lock the resource.
Parameters
| bool | $blocking | wait until the lock is released |
Return Value
| bool | Returns true if the lock was acquired, false otherwise |
Exceptions
| IOException | If the lock file could not be created or opened |
release()
Release the resource.
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Filesystem/LockHandler.html