gielfeldt/lock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gielfeldt/lock

Composer 安装命令:

composer require gielfeldt/lock

包简介

Lock library.

README 文档

README

Build Status Test Coverage Scrutinizer Code Quality Code Climate

Latest Stable Version Latest Unstable Version Dependency Status License Total Downloads

Documentation Status Documentation Status

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

  1. "Easy" API (™)
  2. Separate storage logic to avoid boilerplate
  3. Ensure release on lock destruction
  4. Optionally persistent across requests
  5. Event handlers on e.g. release
  6. 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

  1. Lots probably.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-20