gielfeldt/lock
Composer 安装命令:
composer require gielfeldt/lock
包简介
Lock library.
关键字:
README 文档
README
Installation
To install the Lock library in your project using Composer, first add the following to your composer.json
config file.
{ "require": { "gielfeldt/lock": "~1.0" } }
Then run Composer's install or update commands to complete installation. Please visit the Composer homepage for more information about how to use Composer.
Lock
This lock handler ...
Motivation/objectives
- "Easy" API (™)
- Separate storage logic to avoid boilerplate
- Ensure release on lock destruction
- Optionally persistent across requests
- Event handlers on e.g. release
- Force release (by non-owner)
Example 1 - using Lock library
namespace Gielfeldt\Lock\Example; require 'vendor/autoload.php'; use Gielfeldt\Lock; $lockService = new Lock\LockService([ 'storage' => new Lock\Storage\Memory(), ]); print "'mylock' is locked: " . $lockService->isLocked('mylock') . "\n"; print "Locking 'mylock'\n"; $lock = $lockService->acquire('mylock'); print "'mylock' is locked: " . $lockService->isLocked('mylock') . "\n"; $lock->bind('release', function ($lock) { print "RELEASE EVENT 2: " . $lock->getName() . "\n"; }); $lock->release(); print "'mylock' is locked: " . $lockService->isLocked('mylock') . "\n";
For more examples see the examples/ folder.
Features
- Use arbitrary storage backends for locks
- Persist locks across scripts
- Ensure release of locks on end-of-scope
- Attach custom event handlers on lock release
Caveats
- Lots probably.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-20