首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > PHP > 一个简单的基于文件的PHP的锁定机制

一个简单的基于文件的PHP的锁定机制

资 源 简 介

This project provides a SIMPLE standa-lone multi-platform way to extablish mutex locks in php scripts. I needed this to ensure that a scheduled cron job wouldn"t run UNTIL another script was finished. It works by putting a lock on a temp file that is named according to the lock name but with all the non alphanumeric characters stripped out. It is VERY easy to use. $mutex = new Mutex("attendeeEmail");while(!$mutex->getLock()){ sleep(.5);}//Do tasks that should never be run more than one at a time.$mutex->releaseLock(); There is also a "isLocked" method. I just write my scripts to not run if it can"t get a lock. PHP will release the lock when the request is done if you didn"t manually release it. Releasing the lock also closes the open filehandle. Currently it uses the php temporary file functions to find the temp directory. You can easily change this to manually set a writable directory.

文 件 列 表

mutex.php

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP
  • 杨波 11小时前 成为了本站会员

  • ZS 11小时前 成为了本站会员

  • . 1天前 成为了本站会员

  • 奋斗 1天前 成为了本站会员

  • 1天前 成为了本站会员

  • 一天不玩浑身难受 2天前 成为了本站会员

  • Aloha 2天前 成为了本站会员

  • 嘻嘻嘻 2天前 成为了本站会员

  • maihaoweilai 2天前 成为了本站会员

  • 紫麟鹿 2天前 成为了本站会员