kerekit/lockfile 问题修复 & 功能扩展

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

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

kerekit/lockfile

最新稳定版本:2.0.1

Composer 安装命令:

composer require kerekit/lockfile

包简介

Lockfile mechanism with timeout option

README 文档

README

Install

composer install kerekit/lockfile

Example

<?php
use Kerekit\Lockfile\{Exception,Lock};

// Set a lockfile with 4 hours of timeout
$lock = new Lock (__DIR__ . '/lockfile.json', 4 * 60 * 60);

// Pass a callable to Lock::run()
try {
    $lock->run (function () {
        /**
         * Do something here...
         * - If it completes successfully, lockfile is closed, with last
         *   completion time updated.
         * - If an exception is thrown, lockfile is closed, but last completion
         *   time remains the same.
         * - If lockfile's last completion time is too old, fail with an
         *   exception.
         */
    });
}

// Catch lockfile timeout
catch (Exception $e) {
    if ($e->getCode () === Exception::CODE_TIMEOUT) {
        echo "ERROR: Lockfile timeout reached!\n";
        exit (1);
    } else {
        echo "ERROR: Failed to handle lockfile (" . $e->getMessage () . ")\n";
        exit (1);
    }
}

// Ignore any other errors
catch (\Throwable $e) {}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: ISC
  • 更新时间: 2025-02-20