承接 arnapou/lock 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

arnapou/lock

最新稳定版本:v1.4.0

Composer 安装命令:

composer require arnapou/lock

包简介

Library - Simple lock interface and adapters.

README 文档

README

pipeline coverage

This library helps you to manage basic locks for async processes or race condition problems.

Installation

composer require arnapou/lock

packagist 👉️ arnapou/lock

Introduction

This library provides basic lock interfaces and adapters.

It mainly follows the KISS principle.

If you need advanced features, go look at symfony/lock or other equivalent libraries.

Here, the goal is minimalist code for 90% of needs.

Basic usage

$locker = new \Arnapou\Lock\Adapter\RedisLocker(
    redis: $redis,
    autorelease: true,
    defaultTtl: 60,
    namespace: 'project:locks:'  
);

if ($locker->acquire('my_lock')) {
    // do your process
    $locker->release('my_lock');
} else {
    // delay or report an error
}

Decorators

We can enhance the behaviour for instance with a retry mechanism :

$waitingLocker = new \Arnapou\Lock\Decorator\WaitingLocker(
    internal: $redisLocker,
    maxTotalWaitSeconds: 1.0,
    minLoopWaitMilliseconds: 20,
    maxLoopWaitMilliseconds: 150
);

if ($locker->acquire('my_lock')) {
    // do your process
    $locker->release('my_lock');
} else {
    // delay or report an error
}

Php versions

DateRef8.58.48.3
25/10/20251.4.x, main×××
25/11/20241.3.x××
09/01/20241.0 - 1.2×

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固