inhere / lock
This package is abandoned and no longer maintained.
The author suggests using the php-comp/lock package instead.
lock library of the php
v1.1.0
2018-11-22 08:51 UTC
Requires
- php: >7.0.0
Suggests
- inhere/console: a lightweight php console application library.
- inhere/php-validate: Very lightweight data validate tool
This package is auto-updated.
Last update: 2022-02-01 13:07:34 UTC
README
DatabaseLock
数据库方式的共享锁FileLock
文件加锁的方式实现SemaphoreLock
基于信号量(是系统提供的一种原子操作)的方式实现。需php编译时--enable-sysvsem
MemcacheLock
基于memcache实现
安装
- composer
{ "require": { "php-comp/lock": "dev-master" } }
- 直接拉取
git clone https://git.oschina.net/inhere/php-lock.git // git@osc git clone https://github.com/inhere/php-lock.git // github
使用
use PhpComp\Lock\Lock; $locker = new Lock([ 'driver' => '', // allow: File Database Memcache Semaphore 'tmpDir' => '/tmp', // tmp path, if use FileLock ]); $key = 'op1'; if ($locker->lock($key)) { // do something ... $locker->unlock($key); }
License
MIT