开发者

Acquire lock/release lock, solving racing conditions in PHP

开发者 https://www.devze.com 2023-03-27 02:09 出处:网络
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

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

精彩评论

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