定制 paysera/lib-lock-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

paysera/lib-lock-bundle

Composer 安装命令:

composer require paysera/lib-lock-bundle

包简介

Provides utilities to organize Locks in your system

README 文档

README

Provides quick integration with symfony/lock

Installation

  • Install package
composer require paysera/lib-lock-bundle
  • Enable bundle
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Paysera\Bundle\LockBundle\PayseraLockBundle(),
        ];

        // ...
    }
}

Configuration

paysera_lock:
    ttl: 5 # integer, optional
    redis_client: # service id, required

ttl - time for locks TTL in seconds, default 5 seconds.

redis_client - service id for any Redis client service supported by symfony/lock

Usage

  • LockManager::createLock($identifier) - creates lock but not acquires it
  • LockManager::acquire($lock) - acquires lock or throws LockAcquiringException on failure
  • LockManager::createAccuired($identifier) - creates acquired lock or throws LockAcquiringException
  • LockManager::release($lock) - releases lock

Example

$lock = $this->lockManager->createLock($identifier);
try {
    $this->lockManager->acquire($lock);
    
    // do something after aquiring lock
} catch (LockAcquiringException $exception) {
    throw new Exception('...');
} finally {
    $lock->release();
}

OR

try {
    $lock = $this->lockManager->createAcquired($identifier);
} catch (LockAcquiringException $exception) {
    throw new Exception('...');
}

// do rest

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固