Lock
A lock is a mechanism used to control access to a shared resource so that only one process can use it at a time.
There are different kinds of locks:
- File locks, when using
flock()function - Database locks, via transactions or explicit locks in the database
- Semaphore locks, based on sem extension.
<?php
$sem = sem_get(123456);
sem_acquire($sem);
// critical section
sem_release($sem);
?>
See Also
- Data locking strategies in PHP apps. Practical approach
- Locking in PHP to serialize execution of critical sections