开发者

Acquire lock/release lock, solving racing conditions in PHP

Is there any class to acquiring/releasing locks, using different "drivers" for that? Saying "drivers" I mean different backends for locking: locking with files, lockign with memcache, locking with redis, locking with shared memory etc.

Something like...

$Locker = new Locker(new FileLockerDriver());
$Locker->aquire($id);
//do some开发者_如何学JAVAthing here...
$Locker->release($id);

Thank you.


There is no mechanism like the one you described, but there are multiple lock functionalities: There is flock() (a file-lock) and Semaphores. There may be more that I do not know of.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜