承接 crazedsanity/lockfile 相关项目开发

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

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

crazedsanity/lockfile

最新稳定版本:v0.1.3

Composer 安装命令:

composer require crazedsanity/lockfile

包简介

Create a *.lock file, such as to lock down upgrades from running concurrently.

README 文档

README

This class is intended to avoid having multiple instances of a certain process (like an upgrade, such as with cs_webdbupgrade) from "tripping" over each other. Create a lock file somewhere on the system (which is readable + writable), and remove it when the operation completes. The file should stay if there's a problem that keeps the operation from completing (because trying again would probably fail, or would make things worse).

use crazedsanity\lockfile\LockFile;

$lock = new LockFile('/path/to/rw/dir', 'file.lock');

if(!$lock->is_lockfile_present()) {
	$lock->create_lockfile($upgradeWording);
	
	// ... do some stuff...
	// Only delete the lockfile if it all succeeded
	$lock->delete_lockfile();
}
else {
	throw new exception($lock->read_lockfile());
}

You may want to look at Web DB Upgrade for an implementation example.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-15