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.
精彩评论