首页| 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
0.195825s